From 5016f8d86a8f8d481a9331c4a394cb3a97660a0c Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 23 Jul 2016 21:24:29 +0000 Subject: [PATCH] Parse transaction weights into blktxn_t structure ABI break: sizeof(blktxn_t) has been increased, so accesses to blktmpl_t->txns[>0] use a different offset (aside, hash_ and txid are moved) New ABI supports up to 512 MB transactions (with a max weight-per-bytes of 4), and library gracefully interprets larger weight values as -1 (unknown) --- blkmaker_jansson.c | 9 +++++++++ blktemplate.h | 1 + 2 files changed, 10 insertions(+) diff --git a/blkmaker_jansson.c b/blkmaker_jansson.c index 709b7a8..8865683 100644 --- a/blkmaker_jansson.c +++ b/blkmaker_jansson.c @@ -163,6 +163,15 @@ const char *parse_txn(struct blktxn_t *txn, json_t *txnj) { } } + txn->weight = -1; + if ((vv = json_object_get(txnj, "weight")) && json_is_number(vv)) { + const double f = json_number_value(txnj); + const int32_t i32 = f; + if (f == i32) { + txn->weight = i32; + } + } + // TODO: dependcount/depends, fee, required, sigops return NULL; diff --git a/blktemplate.h b/blktemplate.h index d3a80c6..f048356 100644 --- a/blktemplate.h +++ b/blktemplate.h @@ -39,6 +39,7 @@ struct blktxn_t { uint64_t fee; bool required; int16_t sigops; + int32_t weight; txnhash_t *hash_; txnhash_t *txid;