Page MenuHomePhabricator

RPC: Introduce getblockstats to plot things
ClosedPublic

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

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Commits
rABCb0ec7a2db413: RPC: Introduce getblockstats to plot things
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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Fabien created this revision.Mon, Jul 29, 10:32
Herald added a reviewer: Restricted Project. · View Herald TranscriptMon, Jul 29, 10:32
deadalnix accepted this revision.Thu, Aug 1, 06:12
This revision is now accepted and ready to land.Thu, Aug 1, 06:12
This revision was automatically updated to reflect the committed changes.