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
    0$ ./src/bitcoin-cli -netinfo help
    
    • to see the updated short help
    0$ ./src/bitcoin-cli -help | grep -A4 netinfo
    
     0$ ./src/bitcoin-cli -netinfo help
     1-netinfo level|"help" 
     2
     3Returns a network peer connections dashboard with information from the remote server.
     4Under the hood, -netinfo fetches the data by calling getpeerinfo and getnetworkinfo.
     5An optional integer argument from 0 to 4 can be passed for different peers listings.
     6Pass "help" to see this detailed help documentation.
     7If more than one argument is passed, only the first one is read and parsed.
     8Suggestion: use with the Linux watch(1) command for a live dashboard; see example below.
     9
    10Arguments:
    111. level (integer 0-4, optional)  Specify the info level of the peers dashboard (default 0):
    12                                  0 - Connection counts and local addresses
    13                                  1 - Like 0 but with a peers listing (without address or version columns)
    14                                  2 - Like 1 but with an address column
    15                                  3 - Like 1 but with a version column
    16                                  4 - Like 1 but with both address and version columns
    172. help (string "help", optional) Print this help documentation instead of the dashboard.
    18
    19Result:
    20
    21* The peers listing in levels 1-4 displays all of the peers sorted by direction and minimum ping time:
    22
    23  Column   Description
    24  ------   -----------
    25  <->      Direction
    26           "in"  - inbound connections are those initiated by the peer
    27           "out" - outbound connections are those initiated by us
    28  type     Type of peer connection
    29           "full"   - full relay, the default
    30           "block"  - block relay; like full relay but does not relay transactions or addresses
    31  net      Network the peer connected through ("ipv4", "ipv6", "onion", "i2p", or "cjdns")
    32  mping    Minimum observed ping time, in milliseconds (ms)
    33  ping     Last observed ping time, in milliseconds (ms)
    34  send     Time since last message sent to the peer, in seconds
    35  recv     Time since last message received from the peer, in seconds
    36  txn      Time since last novel transaction received from the peer and accepted into our mempool, in minutes
    37  blk      Time since last novel block passing initial validity checks received from the peer, in minutes
    38  age      Duration of connection to the peer, in minutes
    39  asmap    Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying
    40           peer selection (only displayed if the -asmap config option is set)
    41  id       Peer index, in increasing order of peer connections since node startup
    42  address  IP address and port of the peer
    43  version  Peer version and subversion concatenated, e.g. "70016/Satoshi:21.0.0/"
    44
    45* The connection counts table displays the number of peers by direction, network, and the totals
    46  for each, as well as a column for block relay peers.
    47
    48* The local addresses table lists each local address broadcast by the node, the port, and the score.
    49
    50Examples:
    51
    52Connection counts and local addresses only
    53> bitcoin-cli -netinfo
    54
    55Compact peers listing
    56> bitcoin-cli -netinfo 1
    57
    58Full dashboard
    59> bitcoin-cli -netinfo 4
    60
    61Full live dashboard, adjust --interval or --no-title as needed (Linux)
    62> watch --interval 1 --no-title bitcoin-cli -netinfo 4
    63
    64See this help
    65> bitcoin-cli -netinfo help
    
  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:

    0            "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

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

    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:

     0$ src/bitcoin-cli -regtest -netinfo help
     1[help text]
     2$ src/bitcoin-cli -regtest -netinfo 0
     3Bitcoin Core v21.99.0-cd42490f045aa2c3454d0c5518199119f5d1ea7d regtest - 70016/Satoshi:21.99.0/
     4
     5        ipv4    ipv6   onion   total  block-relay
     6in         0       0       0       0       0
     7out        0       0       0       0       0
     8total      0       0       0       0       0
     9
    10Local addresses: n/a
    11$ src/bitcoin-cli -regtest -netinfo hel
    12Bitcoin Core v21.99.0-cd42490f045aa2c3454d0c5518199119f5d1ea7d regtest - 70016/Satoshi:21.99.0/
    13
    14        ipv4    ipv6   onion   total  block-relay
    15in         0       0       0       0       0
    16out        0       0       0       0       0
    17total      0       0       0       0       0
    18
    19Local 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!

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

    Updates:

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

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

    0$ ./src/bitcoin-cli -netinfo he1
    1error: invalid -netinfo argument: he1
    2$ ./src/bitcoin-cli -netinfo ho ho ho
    3error: invalid -netinfo argument: ho
    
    1. make the last example like the other ones (just noticed this)
    0-            "> watch --interval 1 --no-title ./src/bitcoin-cli -netinfo 4\n\n"
    1+            "> 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: 2024-12-18 21:12 UTC

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