From 3c7889fa23e30cc90ed567029dd9986028e2e41d Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 26 Jul 2016 03:08:03 +0000 Subject: [PATCH] Keep a tally of total sigops in blktmpl_t->txns (if known) --- blkmaker_jansson.c | 9 +++++++++ blktemplate.h | 1 + 2 files changed, 10 insertions(+) diff --git a/blkmaker_jansson.c b/blkmaker_jansson.c index 390b08a..f2d4ad5 100644 --- a/blkmaker_jansson.c +++ b/blkmaker_jansson.c @@ -283,6 +283,7 @@ const char *blktmpl_add_jansson(blktemplate_t *tmpl, const json_t *json, time_t size_t txns = tmpl->txncount = json_array_size(v); tmpl->txns = malloc(txns * sizeof(*tmpl->txns)); tmpl->txns_datasz = 0; + tmpl->txns_sigops = 0; for (size_t i = 0; i < txns; ++i) { struct blktxn_t * const txn = &tmpl->txns[i]; @@ -290,6 +291,14 @@ const char *blktmpl_add_jansson(blktemplate_t *tmpl, const json_t *json, time_t return s; } tmpl->txns_datasz += txn->datasz; + if (tmpl->txns_sigops == -1) { + ; // Impossible to tally the unknown + } else if (txn->sigops_ == -1) { + tmpl->txns_sigops = -1; + } else { + tmpl->txns_sigops += txn->sigops_; + } + tmpl->txns_sigops += txn->sigops_; } if ((v = json_object_get(json, "coinbasetxn")) && json_is_object(v)) diff --git a/blktemplate.h b/blktemplate.h index e675bee..8f3f7af 100644 --- a/blktemplate.h +++ b/blktemplate.h @@ -139,6 +139,7 @@ typedef struct { struct blkaux_t *auxs; unsigned long txns_datasz; + signed long txns_sigops; } blktemplate_t; extern void blktxn_init(struct blktxn_t *);