rpc: add `getblockchaininfo` and `getnetworkinfo` #4127

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2014_05_rpcnetwork changing 6 files +100 −7
  1. laanwj commented at 11:41 AM on May 5, 2014: member

    Adds two new info query commands that take over information from hodge-podge getinfo.

    Also some useful new information is added:

    • getblockchaininfo
      • chain: (string) current chain (main, testnet3, regtest)
      • verificationprogress: (numeric) estimated verification progress
      • bestblockhash: (string) the hash of the currently best block
      • chainwork
    • getnetworkinfo
      • numblocksofpeers: (numeric) number of blocks of peers, as estimated from version messages; same as shown in the GUI
      • localaddresses: (array) local addresses, from mapLocalHost (fixes #1734)

    Example getnetworkinfo:

    {
        "version" : 99900,
        "protocolversion" : 70002,
        "timeoffset" : 0,
        "connections" : 8,
        "proxy" : "",
        "relayfee" : 0.00001000,
        "localaddresses" : [
            {
                "address" : "89.98.179.240",
                "port" : 8333,
                "score" : 4
            }
        ]
    }
    

    Example getblockchaininfo:

    {
        "chain" : "main",
        "blocks" : 299320,
        "bestblockhash" : "00000000000000000fe7330173c917964dff6c763478a8ad7ee18998069bcfff",
        "difficulty" : 8000872135.96816349,
        "verificationprogress" : 0.99996298,
        "chainwork" : "0000000000000000000000000000000000000000000055887ab265d0a5977101"
    }
    

    This is analogous to getwalletinfo that was introduced by pull #3717.

  2. gavinandresen commented at 12:42 PM on May 5, 2014: contributor

    Untested ACK.

    I'd vote for adding best-block-hash to getblockchaininfo.

  3. laanwj commented at 2:09 PM on May 5, 2014: member

    Ok, added bestblockhash.

    The only field from getinfo that I don't know where to place otherwise is errors, as it reports errors from different sources

    • anything that sets strMiscWarning (blockchain code sets this, as well as P2P network interaction in main)
    • various block chain warnings
    • pre-release build warning
    • alerts

    Instead of returning only the message with the highest priority, maybe it makes sense to add a getwarnings call that returns all active runtime warnings along with their priority?

  4. jgarzik commented at 4:45 PM on May 5, 2014: contributor

    ACK

  5. sipa commented at 5:18 PM on May 5, 2014: member

    Maybe adding nChainWork would be useful to expose here as well. (optional, not needed in this PR).

  6. rpc: add `getblockchaininfo` and `getnetworkinfo`
    Adds two new info query commands that take over information from
    hodge-podge `getinfo`.
    
    Also some new information is added:
    - `getblockchaininfo`
      - `chain`: (string) current chain (main, testnet3, regtest)
      - `verificationprogress: (numeric) estimated verification progress
      - `chainwork`
    - `getnetworkinfo`
      - `localaddresses`: (array) local addresses, from mapLocalHost (fixes #1734)
    d387b8ec15
  7. laanwj commented at 7:35 AM on May 6, 2014: member
    • Removed numblocksofpeers after discussion on IRC yesterday. Would be better to get rid of it in the GUI as well (and instead show the list of connected nodes with their raw values in the debug window?).
    <gmaxwell> wumpus: I'm unsure about that numblocksofpeers... there really isn't a good way to indicate in the output "This figure is not authenticated in any way and you shouldn't depend on it for anything— it can display complete rubbish, and troublemakers have screwed with it in the past."
    <wumpus> gmaxwell: right, I just want the same information available in the RPC interface in the GUI
    <wumpus> gmaxwell: if we don't want it on the RPC interface, I'd want to remove it from the GUI too
    <wumpus> gmaxwell: (which isn't too much of an issue as the progress display uses the progress estimate)
    <gmaxwell> I don't think it's that terribly useful in either (now that we have the progress estimate). Getpeerinfo gives the per peer raw values, which are more useful.
    <wumpus> ok, agreed, let's just remove it then
    <sipa> gmaxwell, wumpus: ACK
    
    • added chainwork
  8. BitcoinPullTester commented at 8:10 AM on May 6, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/d387b8ec15e553db9b9c370314ee359e981fb374 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  9. laanwj added this to the milestone 0.9.2 on May 6, 2014
  10. laanwj merged this on May 6, 2014
  11. laanwj closed this on May 6, 2014

  12. laanwj referenced this in commit acc2d2ca5f on May 6, 2014
  13. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me