Skip to content

Conversation

@UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Aug 15, 2019

Fixes #2519

This rpc was introduced in Bitcoin Core 0.17 and we are still finishing 0.15 backports. However, it looks more or less trivial to backport this one and it shouldn't cause merge conflicts in the future as far as I can see. I dashified it already i.e. s/satoshis/duffs/, dropped segwit related stats and switched some stats to use size/bytes instead of weight/vbytes in calculations.

Note: getblockstats somehash is kind of broken which is a known issue bitcoin#15412 and it's not fixed yet (because it requires some deeper/controversial changes in rpc module itself).

Original commits:

41d0476 Tests: Add data file (Anthony Towns)
4cbfb6a Tests: Test new getblockstats RPC (Jorge Timón)
35e77a0 RPC: Introduce getblockstats (Jorge Timón)
cda8e36 Refactor: RPC: Separate GetBlockChecked() from getblock() (Jorge Timón)

Original pull request description:

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.

Tree-SHA512: 2b2787a3c7dc4a11df1fce62c8a4c748f5347d7f7104205d5f0962ffec1e0370c825b49fd4d58ce8ce86bf39d8453f698bcd46206eea505f077541ca7d59b18c

@UdjinM6 UdjinM6 added the RPC Some notable changes to RPC params/behaviour/descriptions label Aug 15, 2019
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the extra three lines added contrary to the initial pull

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question :) That's because I converted the test to use mocktime and not realtime when generating blocks for the test thus I needed https://github.com/dashpay/dash/pull/3058/files/0aa34ea89cf3630342e9ed6aa49291652cdccc83#diff-dbccfb6d2ff211cd44b8f5e532e3238aR13 and also, we have no set_test_params functionality yet so had to convert it to def __init__(self): + super().__init__() https://github.com/dashpay/dash/pull/3058/files/0aa34ea89cf3630342e9ed6aa49291652cdccc83#diff-dbccfb6d2ff211cd44b8f5e532e3238aR47.

get_mocktime is deprecated after #3049 however, so I rebased it (with no changes) and added 3a01dfb on top.

laanwj and others added 2 commits August 21, 2019 01:21
41d0476 Tests: Add data file (Anthony Towns)
4cbfb6a Tests: Test new getblockstats RPC (Jorge Timón)
35e77a0 RPC: Introduce getblockstats (Jorge Timón)
cda8e36 Refactor: RPC: Separate GetBlockChecked() from getblock() (Jorge Timón)

Pull request description:

  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.

Tree-SHA512: 2b2787a3c7dc4a11df1fce62c8a4c748f5347d7f7104205d5f0962ffec1e0370c825b49fd4d58ce8ce86bf39d8453f698bcd46206eea505f077541ca7d59b18c
Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

Copy link

@codablock codablock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

const uint256 hash = ParseHashV(request.params[0], "parameter 1");
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
pindex = mapBlockIndex[hash];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit and I'm fine if you leave it this way, but I'm generally a big fan of .at(key) instead of the [] operator in cases you expect that the value is present 100% of the time and that non-presence is actually a bug. .at(key) will assert in case the value is not present while [] will create a default initialized value and return it (which will be much worse then an immediate crash).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. But that's the way it's implemented in many other places as well and this thing is going to be refactored later, so I'd prefer to keep it as is.

@UdjinM6 UdjinM6 merged commit f2dcac3 into dashpay:develop Aug 28, 2019
@UdjinM6 UdjinM6 added this to the 14.1 milestone Sep 30, 2019
@UdjinM6 UdjinM6 deleted the merge10757 branch November 26, 2020 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC Some notable changes to RPC params/behaviour/descriptions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants