Page MenuHomePhabricator

RPC: Introduce getblockstats to plot things
ClosedPublic

Authored by Fabien on Jul 29 2019, 10:32.

Details

Summary
It returns per block statistics about several things. It should be easy
to add more if people think of other things to add or remove some if I
went too far (but once written, why not keep it? EDIT: answer: not to
test or maintain them).

The currently available options are:
minfee,maxfee,totalfee,minfeerate,maxfeerate,avgfee,avgfeerate,txs,ins,outs
(EDIT: see updated list in the rpc call documentation)

For the x axis, one can use height or block.nTime (I guess I could add
mediantime if there's interest [EDIT: nobody showed interest but I
implemented mediantime nonetheless, in fact there's no distinction
between x or y axis anymore, that's for the caller to judge]).

To calculate fees, -txindex is required.

Partial backport of core PR10757 (commits 35e77a0, 4cbfb6a and 41d0476)
https://github.com/bitcoin/bitcoin/pull/10757/files

Depends on D3755.

The behavior of the getblockstats RPC has been changed from the PR:

  • It does not include segwit related statistics
  • The amounts are expressed in BCH instead of Satoshis. This make it consistent with other RPCs.
Test Plan
make check
./src/bitcoin-cli help getblockstats
./test/functional/test_runner.py rpc_getblockstats --gen-test-data
./test/functional/test_runner.py rpc_getblockstats

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable