Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rpc] fix getchaintxstats() #11021

Merged
merged 2 commits into from Oct 2, 2017
Merged

Commits on Aug 25, 2017

  1. Fix getchaintxstats()

    1. Calculate nblocks more adaptive.
       If not specify nblocks-parameter, illegal parameter error
       will happen when target block height is below blocks for 1 month.
       To avoid this error, set default nblocks to
       min(blocks for 1 month, target block's height - 1)
       And allowing 0 so that this RPC works good even if target block is
       genesis block or 1st block.
    2. Correct error message.
       nblocks accepts [0 .. block's height -1] . so fix as following:
       "Invalid block count: should be between 0 and the block's height - 1"
    3. Add check 0-divide.
       If nTimeDiff = 0 then returns {... "txrate":} and
       bitcoin-cli cannot handle the response.
       To avoid this error, do not return "txrate" if nTimeDiff = 0.
    4. Add following 3 elements to the return object.
       1) 'window_block_count' : Size of the window in number of blocks.
       2) 'window_tx_count' : The number of transactions in the window.
       3) 'window_interval' : The elapsed time in the window.
       They clarify how 'txrate' is calculated. 2) and 3) are returned
       only if 'window_block_count' is a positive value.
    5. Improve help text for 'time' as following.
       'The timestamp for the final block in the window in UNIX format.
    AkioNak committed Aug 25, 2017
    Configuration menu
    Copy the full SHA
    3336676 View commit details
    Browse the repository at this point in the history
  2. Add some tests for getchaintxstats

    1. Add a test for no parameters.
    2. Add a test for the block's height = 1.
    3. Add a test for nblocks is out of range.
    AkioNak committed Aug 25, 2017
    Configuration menu
    Copy the full SHA
    07704c1 View commit details
    Browse the repository at this point in the history