Skip to content

Commit 4baa162

Browse files
committed
Merge bitcoin/bitcoin#29212: Fix -netinfo backward compat with getpeerinfo pre-v26
5fa7460 Fix -netinfo backward compat with getpeerinfo pre-v26 (Jon Atack) Pull request description: Commit fb5bfed in #29058 will cause `-netinfo` to break when calling it on a node that is running pre-v26 bitcoind, as `getpeerinfo` doesn't yet return a "transport_protocol_type" field. Fix this by adding an `IsNull()` check, as already done for other recent getpeerinfo fields, and also in the same commit: a) avoid checking for the full string "detecting", and instead do the cheaper check for the most frequent case of the string starting with "v" b) drop displaying the "v" prefix in all the rows, as it doesn't add useful information, and instead use "v" for the column header c) display nothing when a value isn't determined yet, like for the -netinfo mping and ping columns (as `*` already has a separate meaning in this dashboard, and `?` might look like there is a bug) ACKs for top commit: mzumsande: Code Review ACK 5fa7460 achow101: ACK 5fa7460 kristapsk: ACK 5fa7460 Tree-SHA512: 4afc513dc669b95037180008eb4c57fc0a0d742c02f24b236562d6b8daad5c120eb1ce0d90e51696e0f9b8361a72fc930c0b64f04902cf96fb48c8e042e58624
2 parents bb6de1b + 5fa7460 commit 4baa162

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/bitcoin-cli.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
518518
const std::string addr{peer["addr"].get_str()};
519519
const std::string age{conn_time == 0 ? "" : ToString((time_now - conn_time) / 60)};
520520
const std::string sub_version{peer["subver"].get_str()};
521-
const std::string transport{peer["transport_protocol_type"].get_str()};
521+
const std::string transport{peer["transport_protocol_type"].isNull() ? "v1" : peer["transport_protocol_type"].get_str()};
522522
const bool is_addr_relay_enabled{peer["addr_relay_enabled"].isNull() ? false : peer["addr_relay_enabled"].get_bool()};
523523
const bool is_bip152_hb_from{peer["bip152_hb_from"].get_bool()};
524524
const bool is_bip152_hb_to{peer["bip152_hb_to"].get_bool()};
@@ -538,7 +538,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
538538
// Report detailed peer connections list sorted by direction and minimum ping time.
539539
if (DetailsRequested() && !m_peers.empty()) {
540540
std::sort(m_peers.begin(), m_peers.end());
541-
result += strprintf("<-> type net tp mping ping send recv txn blk hb %*s%*s%*s ",
541+
result += strprintf("<-> type net v mping ping send recv txn blk hb %*s%*s%*s ",
542542
m_max_addr_processed_length, "addrp",
543543
m_max_addr_rate_limited_length, "addrl",
544544
m_max_age_length, "age");
@@ -551,7 +551,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
551551
peer.is_outbound ? "out" : "in",
552552
ConnectionTypeForNetinfo(peer.conn_type),
553553
peer.network,
554-
peer.transport_protocol_type == "detecting" ? "*" : peer.transport_protocol_type,
554+
peer.transport_protocol_type.starts_with('v') ? peer.transport_protocol_type[1] : ' ',
555555
PingTimeToString(peer.min_ping),
556556
PingTimeToString(peer.ping),
557557
peer.last_send ? ToString(time_now - peer.last_send) : "",
@@ -661,7 +661,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
661661
" \"feeler\" - short-lived connection for testing addresses\n"
662662
" \"addr\" - address fetch; short-lived connection for requesting addresses\n"
663663
" net Network the peer connected through (\"ipv4\", \"ipv6\", \"onion\", \"i2p\", \"cjdns\", or \"npr\" (not publicly routable))\n"
664-
" tp Transport protocol used for the connection (\"v1\", \"v2\" or \"*\" if detecting)\n"
664+
" v Version of transport protocol used for the connection\n"
665665
" mping Minimum observed ping time, in milliseconds (ms)\n"
666666
" ping Last observed ping time, in milliseconds (ms)\n"
667667
" send Time since last message sent to the peer, in seconds\n"

0 commit comments

Comments
 (0)