doc: add -netinfo help #20829

pull jonatack wants to merge 1 commits into bitcoin:master from jonatack:netinfo-help-doc changing 1 files +67 −3
  1. jonatack commented at 3:24 PM on January 2, 2021: member

    This is the help doc commit of #20764 without the rest of the PR or anything new since the 0.21.0 branch-off in order to target giving users a -netinfo help doc for 0.21.

    • to test the new help
    $ ./src/bitcoin-cli -netinfo help
    
    • to see the updated short help
    $ ./src/bitcoin-cli -help | grep -A4 netinfo
    

    <details><summary><code>-netinfo</code> help doc</summary><p>

    $ ./src/bitcoin-cli -netinfo help
    -netinfo level|"help" 
    
    Returns a network peer connections dashboard with information from the remote server.
    Under the hood, -netinfo fetches the data by calling getpeerinfo and getnetworkinfo.
    An optional integer argument from 0 to 4 can be passed for different peers listings.
    Pass "help" to see this detailed help documentation.
    If more than one argument is passed, only the first one is read and parsed.
    Suggestion: use with the Linux watch(1) command for a live dashboard; see example below.
    
    Arguments:
    1. level (integer 0-4, optional)  Specify the info level of the peers dashboard (default 0):
                                      0 - Connection counts and local addresses
                                      1 - Like 0 but with a peers listing (without address or version columns)
                                      2 - Like 1 but with an address column
                                      3 - Like 1 but with a version column
                                      4 - Like 1 but with both address and version columns
    2. help (string "help", optional) Print this help documentation instead of the dashboard.
    
    Result:
    
    * The peers listing in levels 1-4 displays all of the peers sorted by direction and minimum ping time:
    
      Column   Description
      ------   -----------
      <->      Direction
               "in"  - inbound connections are those initiated by the peer
               "out" - outbound connections are those initiated by us
      type     Type of peer connection
               "full"   - full relay, the default
               "block"  - block relay; like full relay but does not relay transactions or addresses
      net      Network the peer connected through ("ipv4", "ipv6", "onion", "i2p", or "cjdns")
      mping    Minimum observed ping time, in milliseconds (ms)
      ping     Last observed ping time, in milliseconds (ms)
      send     Time since last message sent to the peer, in seconds
      recv     Time since last message received from the peer, in seconds
      txn      Time since last novel transaction received from the peer and accepted into our mempool, in minutes
      blk      Time since last novel block passing initial validity checks received from the peer, in minutes
      age      Duration of connection to the peer, in minutes
      asmap    Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying
               peer selection (only displayed if the -asmap config option is set)
      id       Peer index, in increasing order of peer connections since node startup
      address  IP address and port of the peer
      version  Peer version and subversion concatenated, e.g. "70016/Satoshi:21.0.0/"
    
    * The connection counts table displays the number of peers by direction, network, and the totals
      for each, as well as a column for block relay peers.
    
    * The local addresses table lists each local address broadcast by the node, the port, and the score.
    
    Examples:
    
    Connection counts and local addresses only
    > bitcoin-cli -netinfo
    
    Compact peers listing
    > bitcoin-cli -netinfo 1
    
    Full dashboard
    > bitcoin-cli -netinfo 4
    
    Full live dashboard, adjust --interval or --no-title as needed (Linux)
    > watch --interval 1 --no-title bitcoin-cli -netinfo 4
    
    See this help
    > bitcoin-cli -netinfo help
    
    

    </p></details>

  2. DrahtBot added the label Docs on Jan 2, 2021
  3. michaelfolkson commented at 6:48 PM on January 2, 2021: contributor

    Very detailed help, looks great. Followed your above instructions and looked over code.

    ACK 2a742a7d63d028e32b584aafdee6bc533d566ade

  4. in src/bitcoin-cli.cpp:362 in 2a742a7d63 outdated
     357 | +            "Returns a network peer connections dashboard with information from the remote server.\n"
     358 | +            "Under the hood, -netinfo fetches the data by calling getpeerinfo and getnetworkinfo.\n"
     359 | +            "An optional integer argument from 0 to 4 can be passed for different peers listings.\n"
     360 | +            "Pass \"help\" to see this detailed help documentation.\n"
     361 | +            "If more than one argument is passed, only the first one is read and parsed.\n"
     362 | +            "Suggestion: use with the Linux watch command for a live dashboard; see example below.\n\n"
    


    theStack commented at 7:26 PM on January 2, 2021:

    nit, feel free to ignore: Could use a common Unix/Linux syntax here, putting the manpage section in parantheses:

                "Suggestion: use with the Linux watch(1) command for a live dashboard; see example below.\n\n"
    

    jonatack commented at 7:45 PM on January 2, 2021:

    good idea; done

  5. theStack approved
  6. theStack commented at 7:28 PM on January 2, 2021: member

    ACK 2a742a7d63d028e32b584aafdee6bc533d566ade 📝

  7. jonatack force-pushed on Jan 2, 2021
  8. theStack approved
  9. theStack commented at 7:49 PM on January 2, 2021: member

    re-ACK 2fc153dfa8f3f1417f576c4a28bc46b6aedc19c3 (verified that the only change since my previous ACK was replacing "watch" by "watch(1)" in the "Suggestion: ..." string.)

  10. DrahtBot commented at 9:20 PM on January 2, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #20764 (cli -netinfo peer connections dashboard updates 🎄 ✨ by jonatack)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  11. jonatack commented at 9:50 PM on January 2, 2021: member

    @theStack you may have seen it already, but #20764 also adds the bip152-hb fields to the -netinfo dashboard that you provided in #19776.

  12. michaelfolkson commented at 3:45 PM on January 4, 2021: contributor

    Re-ACK 2fc153dfa8f3f1417f576c4a28bc46b6aedc19c3

  13. jonatack commented at 4:43 PM on January 4, 2021: member

    Thanks @theStack and @michaelfolkson for the review ACKs.

    Maintainers, this help doc targets 0.21.0, please consider it for backport to 0.21.0rc6.

  14. RiccardoMasutti approved
  15. RiccardoMasutti commented at 4:06 PM on January 5, 2021: contributor

    ACK 2fc153d

  16. in src/bitcoin-cli.cpp:356 in 2fc153dfa8 outdated
     349 | @@ -349,6 +350,62 @@ class NetinfoRequestHandler : public BaseRequestHandler
     350 |          const double milliseconds{round(1000 * seconds)};
     351 |          return milliseconds > 999999 ? "-" : ToString(milliseconds);
     352 |      }
     353 | +    const UniValue NetinfoHelp()
     354 | +    {
     355 | +        return std::string{
     356 | +            "-netinfo level \"help\" \n\n"
    


    laanwj commented at 4:41 PM on January 5, 2021:

    Wouldn't this be better summarized as -netlinfo level|"help" instead of a separate argument?

    I've also noticed that it doesn't error out on invalid values:

    $ src/bitcoin-cli -regtest -netinfo help
    [help text]
    $ src/bitcoin-cli -regtest -netinfo 0
    Bitcoin Core v21.99.0-cd42490f045aa2c3454d0c5518199119f5d1ea7d regtest - 70016/Satoshi:21.99.0/
    
            ipv4    ipv6   onion   total  block-relay
    in         0       0       0       0       0
    out        0       0       0       0       0
    total      0       0       0       0       0
    
    Local addresses: n/a
    $ src/bitcoin-cli -regtest -netinfo hel
    Bitcoin Core v21.99.0-cd42490f045aa2c3454d0c5518199119f5d1ea7d regtest - 70016/Satoshi:21.99.0/
    
            ipv4    ipv6   onion   total  block-relay
    in         0       0       0       0       0
    out        0       0       0       0       0
    total      0       0       0       0       0
    
    Local addresses: n/a
    

    jonatack commented at 5:24 PM on January 5, 2021:

    done

  17. jonatack force-pushed on Jan 5, 2021
  18. jonatack commented at 5:32 PM on January 5, 2021: member

    Thanks for the reviews!

    <details><summary><code>git diff 2fc153d 6f2c4fd</code></summary><p>

    diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
    index 7f46cca5bb..94043a6b45 100644
    --- a/src/bitcoin-cli.cpp
    +++ b/src/bitcoin-cli.cpp
    @@ -353,7 +353,7 @@ private:
         const UniValue NetinfoHelp()
         {
             return std::string{
    -            "-netinfo level \"help\" \n\n"
    +            "-netinfo level|\"help\" \n\n"
                 "Returns a network peer connections dashboard with information from the remote server.\n"
                 "Under the hood, -netinfo fetches the data by calling getpeerinfo and getnetworkinfo.\n"
                 "An optional integer argument from 0 to 4 can be passed for different peers listings.\n"
    @@ -402,7 +402,7 @@ private:
                 "Full dashboard\n"
                 "> bitcoin-cli -netinfo 4\n\n"
                 "Full live dashboard, adjust --interval or --no-title as needed (Linux)\n"
    -            "> watch --interval 1 --no-title ./src/bitcoin-cli -netinfo 4\n\n"
    +            "> watch --interval 1 --no-title bitcoin-cli -netinfo 4\n\n"
                 "See this help\n"
                 "> bitcoin-cli -netinfo help\n"};
         }
    @@ -420,6 +420,8 @@ public:
                     m_details_level = n;
                 } else if (args.at(0) == "help") {
                     m_is_help_requested = true;
    +            } else {
    +                throw std::runtime_error(strprintf("invalid -netinfo argument: %s", args.at(0)));
                 }
    

    </p></details>

    Updates:

    1. help begins with -netinfo level|"help"

    2. raise on invalid arg (ignores any args after the first one)

    $ ./src/bitcoin-cli -netinfo he1
    error: invalid -netinfo argument: he1
    $ ./src/bitcoin-cli -netinfo ho ho ho
    error: invalid -netinfo argument: ho
    
    1. make the last example like the other ones (just noticed this)
    -            "> watch --interval 1 --no-title ./src/bitcoin-cli -netinfo 4\n\n"
    +            "> watch --interval 1 --no-title bitcoin-cli -netinfo 4\n\n"
    
  19. jonatack force-pushed on Jan 5, 2021
  20. netinfo: add user help documentation
    and drop no longer needed sort description header to save screen space
    6f2c4fd077
  21. jonatack force-pushed on Jan 5, 2021
  22. laanwj commented at 3:10 PM on January 6, 2021: member

    ACK 6f2c4fd0775a9c45eacc4bab8f138528852fdf44

  23. laanwj merged this on Jan 6, 2021
  24. laanwj closed this on Jan 6, 2021

  25. sidhujag referenced this in commit b33831f81d on Jan 6, 2021
  26. jonatack deleted the branch on Jan 6, 2021
  27. luke-jr commented at 4:48 PM on January 6, 2021: member

    I wonder if this should document that the interface is not stable, should be expected to change regularly, and not scraped?

  28. jonatack commented at 5:00 PM on January 6, 2021: member

    I thought about it, but since it's a client-side-only CLI, ISTM it is by definition intended for use by humans (some reviewers described it as "getpeerinfo for humans") and software clients should depend on getpeerinfo and getnetworkinfo instead, which are subject to API stability constraints.

  29. jonatack commented at 5:01 PM on January 6, 2021: member

    If we think it's worth adding, we can do it in #20764 which is the next step.

  30. jonatack commented at 12:15 PM on January 7, 2021: member

    I wonder if this should document that the interface is not stable, should be expected to change regularly, and not scraped?

    Discussed on IRC today at http://www.erisian.com.au/bitcoin-core-dev/log-2021-01-07.html#l-99. Will update #20764 to document the interface is expected to change regularly.

    Edit: done in #20877.

  31. DrahtBot locked this on Aug 16, 2022

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-14 21:14 UTC

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