From f2a0d3636f8107244bc2251514ab9d0c1aef997e Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 3 Feb 2016 13:49:06 +1100 Subject: [PATCH] Rename transactions to txns to not clash with the transactions value returned by getblocktemplate --- src/bitcoin.c | 22 +++++++++++----------- src/bitcoin.h | 2 +- src/stratifier.c | 30 +++++++++++++++--------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/bitcoin.c b/src/bitcoin.c index 7f9b5f23..92bb7919 100644 --- a/src/bitcoin.c +++ b/src/bitcoin.c @@ -89,18 +89,18 @@ static bool gbt_merkle_bins(gbtbase_t *gbt, json_t *transaction_arr) dealloc(gbt->txn_data); dealloc(gbt->txn_hashes); - gbt->transactions = 0; + gbt->txns = 0; gbt->merkles = 0; - gbt->transactions = json_array_size(transaction_arr); - binlen = gbt->transactions * 32 + 32; + gbt->txns = json_array_size(transaction_arr); + binlen = gbt->txns * 32 + 32; hashbin = alloca(binlen + 32); memset(hashbin, 0, 32); binleft = binlen / 32; - if (gbt->transactions) { + if (gbt->txns) { int len = 1, ofs = 0; const char *txn; - for (i = 0; i < gbt->transactions; i++) { + for (i = 0; i < gbt->txns; i++) { arr_val = json_array_get(transaction_arr, i); txn = json_string_value(json_object_get(arr_val, "data")); if (!txn) { @@ -111,10 +111,10 @@ static bool gbt_merkle_bins(gbtbase_t *gbt, json_t *transaction_arr) } gbt->txn_data = ckzalloc(len + 1); - gbt->txn_hashes = ckzalloc(gbt->transactions * 65 + 1); - memset(gbt->txn_hashes, 0x20, gbt->transactions * 65); // Spaces + gbt->txn_hashes = ckzalloc(gbt->txns * 65 + 1); + memset(gbt->txn_hashes, 0x20, gbt->txns * 65); // Spaces - for (i = 0; i < gbt->transactions; i++) { + for (i = 0; i < gbt->txns; i++) { char binswap[32]; const char *hash; @@ -168,7 +168,7 @@ static bool gbt_merkle_bins(gbtbase_t *gbt, json_t *transaction_arr) binlen = binleft * 32; } } - LOGINFO("Stored %d transactions", gbt->transactions); + LOGINFO("Stored %d transactions", gbt->txns); return true; } @@ -259,8 +259,8 @@ bool gen_gbtbase(connsock_t *cs, gbtbase_t *gbt) json_object_set_new_nocheck(gbt->json, "flags", json_string_nocheck(gbt->flags)); gbt_merkle_bins(gbt, transaction_arr); - json_object_set_new_nocheck(gbt->json, "transactions", json_integer(gbt->transactions)); - if (gbt->transactions) { + json_object_set_new_nocheck(gbt->json, "txns", json_integer(gbt->txns)); + if (gbt->txns) { json_object_set_new_nocheck(gbt->json, "txn_data", json_string_nocheck(gbt->txn_data)); json_object_set_new_nocheck(gbt->json, "txn_hashes", json_string_nocheck(gbt->txn_hashes)); } diff --git a/src/bitcoin.h b/src/bitcoin.h index cb51457f..1404c538 100644 --- a/src/bitcoin.h +++ b/src/bitcoin.h @@ -22,7 +22,7 @@ struct gbtbase { uint64_t coinbasevalue; int height; char *flags; - int transactions; + int txns; char *txn_data; char *txn_hashes; int merkles; diff --git a/src/stratifier.c b/src/stratifier.c index cd21449e..7c73a09b 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -106,7 +106,7 @@ struct workbase { uint64_t coinbasevalue; int height; char *flags; - int transactions; + int txns; char *txn_data; char *txn_hashes; int merkles; @@ -877,8 +877,8 @@ static void send_node_workinfo(sdata_t *sdata, const workbase_t *wb) json_set_int(wb_val, "coinbasevalue", wb->coinbasevalue); json_set_int(wb_val, "height", wb->height); json_set_string(wb_val, "flags", wb->flags); - json_set_int(wb_val, "transactions", wb->transactions); - if (likely(wb->transactions)) + json_set_int(wb_val, "txns", wb->txns); + if (likely(wb->txns)) json_set_string(wb_val, "txn_data", wb->txn_data); /* We don't need txn_hashes */ json_set_int(wb_val, "merkles", wb->merkles); @@ -1158,8 +1158,8 @@ retry: json_uint64cpy(&wb->coinbasevalue, val, "coinbasevalue"); json_intcpy(&wb->height, val, "height"); json_strdup(&wb->flags, val, "flags"); - json_intcpy(&wb->transactions, val, "transactions"); - if (wb->transactions) { + json_intcpy(&wb->txns, val, "txns"); + if (wb->txns) { json_strdup(&wb->txn_data, val, "txn_data"); json_strdup(&wb->txn_hashes, val, "txn_hashes"); } else @@ -1230,8 +1230,8 @@ static void add_node_base(ckpool_t *ckp, json_t *val) json_uint64cpy(&wb->coinbasevalue, val, "coinbasevalue"); json_intcpy(&wb->height, val, "height"); json_strdup(&wb->flags, val, "flags"); - json_intcpy(&wb->transactions, val, "transactions"); - if (wb->transactions) + json_intcpy(&wb->txns, val, "txns"); + if (wb->txns) json_strdup(&wb->txn_data, val, "txn_data"); json_intcpy(&wb->merkles, val, "merkles"); wb->merkle_array = json_object_dup(val, "merklehash"); @@ -1433,7 +1433,7 @@ static void process_block(ckpool_t *ckp, const workbase_t *wb, const char *coinbase, const int cblen, const uchar *data, const uchar *hash, uchar *swap32, char *blockhash) { - int transactions = wb->transactions + 1; + int txns = wb->txns + 1; char *gbt_block, varint[12]; char hexcoinbase[1024]; @@ -1444,17 +1444,17 @@ process_block(ckpool_t *ckp, const workbase_t *wb, const char *coinbase, const i /* Message format: "submitblock:hash,data" */ sprintf(gbt_block, "submitblock:%s,", blockhash); __bin2hex(gbt_block + 12 + 64 + 1, data, 80); - if (transactions < 0xfd) { - uint8_t val8 = transactions; + if (txns < 0xfd) { + uint8_t val8 = txns; __bin2hex(varint, (const unsigned char *)&val8, 1); - } else if (transactions <= 0xffff) { - uint16_t val16 = htole16(transactions); + } else if (txns <= 0xffff) { + uint16_t val16 = htole16(txns); strcat(gbt_block, "fd"); __bin2hex(varint, (const unsigned char *)&val16, 2); } else { - uint32_t val32 = htole32(transactions); + uint32_t val32 = htole32(txns); strcat(gbt_block, "fe"); __bin2hex(varint, (const unsigned char *)&val32, 4); @@ -1462,7 +1462,7 @@ process_block(ckpool_t *ckp, const workbase_t *wb, const char *coinbase, const i strcat(gbt_block, varint); __bin2hex(hexcoinbase, coinbase, cblen); strcat(gbt_block, hexcoinbase); - if (wb->transactions) + if (wb->txns) realloc_strcat(&gbt_block, wb->txn_data); send_generator(ckp, gbt_block, GEN_PRIORITY); if (ckp->remote) @@ -6474,7 +6474,7 @@ static int transactions_by_jobid(sdata_t *sdata, const int64_t id) ck_rlock(&sdata->workbase_lock); HASH_FIND_I64(sdata->workbases, &id, wb); if (wb) - ret = wb->transactions; + ret = wb->txns; ck_runlock(&sdata->workbase_lock); return ret;