Keep a count of total size of all non-generation transactions in templates

This commit is contained in:
Luke Dashjr
2016-01-26 00:23:22 +00:00
parent cc0f35fb8a
commit 2763aba114
2 changed files with 9 additions and 1 deletions

View File

@@ -213,9 +213,15 @@ const char *blktmpl_add_jansson(blktemplate_t *tmpl, const json_t *json, time_t
v = json_object_get(json, "transactions");
size_t txns = tmpl->txncount = json_array_size(v);
tmpl->txns = calloc(txns, sizeof(*tmpl->txns));
tmpl->txns_datasz = 0;
for (size_t i = 0; i < txns; ++i)
if ((s = parse_txn(&tmpl->txns[i], json_array_get(v, i))))
{
struct blktxn_t * const txn = &tmpl->txns[i];
if ((s = parse_txn(txn, json_array_get(v, i)))) {
return s;
}
tmpl->txns_datasz += txn->datasz;
}
if ((v = json_object_get(json, "coinbasetxn")) && json_is_object(v))
{

View File

@@ -134,6 +134,8 @@ typedef struct {
unsigned aux_count;
struct blkaux_t *auxs;
unsigned long txns_datasz;
} blktemplate_t;
extern blktemplate_t *blktmpl_create();