From d8274d6a1cafec73ef52c1b0592236b120104b82 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 13 Jan 2017 10:08:33 +1100 Subject: [PATCH] Allow rebuild_txns to succeed with no transactions listed in the workinfo. --- src/stratifier.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index b597bc24..c13d13bb 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1655,14 +1655,19 @@ static bool rebuild_txns(ckpool_t *ckp, sdata_t *sdata, workbase_t *wb) bool ret = false; int i, len = 0; + /* We'll only see this on testnet now */ + if (unlikely(!wb->txns)) { + ret = true; + goto out; + } if (likely(hashes)) len = strlen(hashes); if (!hashes || !len) - return ret; + goto out; if (unlikely(len < wb->txns * 65)) { LOGERR("Truncated transactions in rebuild_txns only %d long", len); - return ret; + goto out; } ret = true; txn_array = json_array(); @@ -1734,7 +1739,7 @@ static bool rebuild_txns(ckpool_t *ckp, sdata_t *sdata, workbase_t *wb) json_decref(txn_array); json_decref(missing_txns); - +out: return ret; } @@ -1885,10 +1890,8 @@ static void add_node_base(ckpool_t *ckp, json_t *val, bool trusted, int64_t clie /* This is a workbase from a trusted remote */ wb->merkle_array = json_object_dup(val, "merklehash"); json_intcpy(&wb->merkles, val, "merkles"); - if (!rebuild_txns(ckp, sdata, wb)) { + if (!rebuild_txns(ckp, sdata, wb)) wb->incomplete = true; - wb->txns = 0; - } } else { if (!rebuild_txns(ckp, sdata, wb)) { free(wb);