Skip to content

Commit d3cca3b

Browse files
committed
netinfo: update to use peer connection types
1 parent 62bf5b7 commit d3cca3b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/bitcoin-cli.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
322322
struct Peer {
323323
std::string addr;
324324
std::string sub_version;
325+
std::string conn_type;
325326
std::string network;
326327
std::string age;
327328
double min_ping;
@@ -387,6 +388,9 @@ class NetinfoRequestHandler : public BaseRequestHandler
387388
" type Type of peer connection\n"
388389
" \"full\" - full relay, the default\n"
389390
" \"block\" - block relay; like full relay but does not relay transactions or addresses\n"
391+
" \"manual\" - peer we manually added using RPC addnode or the -addnode/-connect config options\n"
392+
" \"feeler\" - short-lived connection for testing addresses\n"
393+
" \"addr\" - address fetch; short-lived connection for requesting addresses\n"
390394
" net Network the peer connected through (\"ipv4\", \"ipv6\", \"onion\", \"i2p\", or \"cjdns\")\n"
391395
" mping Minimum observed ping time, in milliseconds (ms)\n"
392396
" ping Last observed ping time, in milliseconds (ms)\n"
@@ -460,11 +464,12 @@ class NetinfoRequestHandler : public BaseRequestHandler
460464
if (network_id == UNKNOWN_NETWORK) continue;
461465
const bool is_outbound{!peer["inbound"].get_bool()};
462466
const bool is_block_relay{!peer["relaytxes"].get_bool()};
467+
const std::string conn_type{peer["connection_type"].get_str()};
463468
++m_counts.at(is_outbound).at(network_id); // in/out by network
464469
++m_counts.at(is_outbound).at(m_networks_size); // in/out overall
465470
++m_counts.at(2).at(network_id); // total by network
466471
++m_counts.at(2).at(m_networks_size); // total overall
467-
if (is_block_relay) {
472+
if (conn_type == "block-relay-only") {
468473
++m_counts.at(is_outbound).at(m_networks_size + 1); // in/out block-relay
469474
++m_counts.at(2).at(m_networks_size + 1); // total block-relay
470475
}
@@ -483,7 +488,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
483488
const std::string addr{peer["addr"].get_str()};
484489
const std::string age{conn_time == 0 ? "" : ToString((m_time_now - conn_time) / 60)};
485490
const std::string sub_version{peer["subver"].get_str()};
486-
m_peers.push_back({addr, sub_version, network, age, min_ping, ping, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version, is_block_relay, is_outbound});
491+
m_peers.push_back({addr, sub_version, conn_type, network, age, min_ping, ping, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version, is_block_relay, is_outbound});
487492
m_max_addr_length = std::max(addr.length() + 1, m_max_addr_length);
488493
m_max_age_length = std::max(age.length(), m_max_age_length);
489494
m_max_id_length = std::max(ToString(peer_id).length(), m_max_id_length);
@@ -497,15 +502,15 @@ class NetinfoRequestHandler : public BaseRequestHandler
497502
// Report detailed peer connections list sorted by direction and minimum ping time.
498503
if (DetailsRequested() && !m_peers.empty()) {
499504
std::sort(m_peers.begin(), m_peers.end());
500-
result += strprintf("<-> relay net mping ping send recv txn blk %*s ", m_max_age_length, "age");
505+
result += strprintf("<-> type net mping ping send recv txn blk %*s ", m_max_age_length, "age");
501506
if (m_is_asmap_on) result += " asmap ";
502507
result += strprintf("%*s %-*s%s\n", m_max_id_length, "id", IsAddressSelected() ? m_max_addr_length : 0, IsAddressSelected() ? "address" : "", IsVersionSelected() ? "version" : "");
503508
for (const Peer& peer : m_peers) {
504509
std::string version{ToString(peer.version) + peer.sub_version};
505510
result += strprintf(
506-
"%3s %5s %5s%7s%7s%5s%5s%5s%5s %*s%*i %*s %-*s%s\n",
511+
"%3s %6s %5s%7s%7s%5s%5s%5s%5s %*s%*i %*s %-*s%s\n",
507512
peer.is_outbound ? "out" : "in",
508-
peer.is_block_relay ? "block" : "full",
513+
ConnectionTypeForNetinfo(peer.conn_type),
509514
peer.network,
510515
PingTimeToString(peer.min_ping),
511516
PingTimeToString(peer.ping),
@@ -523,7 +528,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
523528
IsAddressSelected() ? peer.addr : "",
524529
IsVersionSelected() && version != "0" ? version : "");
525530
}
526-
result += strprintf(" ms ms sec sec min min %*s\n\n", m_max_age_length, "min");
531+
result += strprintf(" ms ms sec sec min min %*s\n\n", m_max_age_length, "min");
527532
}
528533

529534
// Report peer connection totals by type.

0 commit comments

Comments
 (0)