aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan "Duke" Leto <jonathan@leto.net>2019-08-23 07:42:28 -0700
committerJonathan "Duke" Leto <jonathan@leto.net>2019-08-29 06:24:44 -0700
commitd48c1e837ae1bd08e0f18ad1b57ff72675c3d6ad (patch)
treed24cc7b258e703fafe66d531787a1c614e169b10
parent442a9c64775454a7073aff9872721c58b1dd35c5 (diff)
downloadbitcoin-d48c1e837ae1bd08e0f18ad1b57ff72675c3d6ad.tar.xz
Add window final block height to getchaintxstats
The getchaintxstats RPC now returns the additional key of window_final_block_height
-rw-r--r--doc/release-notes-16695.md5
-rw-r--r--src/rpc/blockchain.cpp2
-rwxr-xr-xtest/functional/rpc_blockchain.py2
3 files changed, 9 insertions, 0 deletions
diff --git a/doc/release-notes-16695.md b/doc/release-notes-16695.md
new file mode 100644
index 0000000000..7acf1dcf97
--- /dev/null
+++ b/doc/release-notes-16695.md
@@ -0,0 +1,5 @@
+Updated RPCs
+------------
+
+- The `getchaintxstats` RPC now returns the additional key of
+ `window_final_block_height`.
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index a74003149d..2d438bec21 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1639,6 +1639,7 @@ static UniValue getchaintxstats(const JSONRPCRequest& request)
" \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n"
" \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n"
" \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n"
+ " \"window_final_block_height\": xxxxx, (numeric) The height of the final block in the window.\n"
" \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n"
" \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n"
" \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n"
@@ -1689,6 +1690,7 @@ static UniValue getchaintxstats(const JSONRPCRequest& request)
ret.pushKV("time", (int64_t)pindex->nTime);
ret.pushKV("txcount", (int64_t)pindex->nChainTx);
ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex());
+ ret.pushKV("window_final_block_height", pindex->nHeight);
ret.pushKV("window_block_count", blockcount);
if (blockcount > 0) {
ret.pushKV("window_tx_count", nTxDiff);
diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py
index 6c30e05084..266a0d6cd2 100755
--- a/test/functional/rpc_blockchain.py
+++ b/test/functional/rpc_blockchain.py
@@ -186,6 +186,7 @@ class BlockchainTest(BitcoinTestFramework):
assert_equal(chaintxstats['time'], b200['time'])
assert_equal(chaintxstats['txcount'], 201)
assert_equal(chaintxstats['window_final_block_hash'], b200_hash)
+ assert_equal(chaintxstats['window_final_block_height'], 200)
assert_equal(chaintxstats['window_block_count'], 199)
assert_equal(chaintxstats['window_tx_count'], 199)
assert_equal(chaintxstats['window_interval'], time_diff)
@@ -195,6 +196,7 @@ class BlockchainTest(BitcoinTestFramework):
assert_equal(chaintxstats['time'], b1['time'])
assert_equal(chaintxstats['txcount'], 2)
assert_equal(chaintxstats['window_final_block_hash'], b1_hash)
+ assert_equal(chaintxstats['window_final_block_height'], 1)
assert_equal(chaintxstats['window_block_count'], 0)
assert 'window_tx_count' not in chaintxstats
assert 'window_interval' not in chaintxstats