Skip to content

Commit 747cb5b

Browse files
committed
netinfo: display only outbound block relay counts
1 parent 76d198a commit 747cb5b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/bitcoin-cli.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ class NetinfoRequestHandler : public BaseRequestHandler
303303
static constexpr int8_t NET_I2P{3}; // pos of "i2p" in m_networks
304304
static constexpr uint8_t m_networks_size{4};
305305
const std::array<std::string, m_networks_size> m_networks{{"ipv4", "ipv6", "onion", "i2p"}};
306-
std::array<std::array<uint16_t, m_networks_size + 2>, 3> m_counts{{{}}}; //!< Peer counts by (in/out/total, networks/total/block-relay)
306+
std::array<std::array<uint16_t, m_networks_size + 1>, 3> m_counts{{{}}}; //!< Peer counts by (in/out/total, networks/total)
307+
uint8_t m_block_relay_peers_count{0};
307308
uint8_t m_manual_peers_count{0};
308309
int8_t NetworkStringToId(const std::string& str) const
309310
{
@@ -478,10 +479,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
478479
++m_counts.at(is_outbound).at(m_networks_size); // in/out overall
479480
++m_counts.at(2).at(network_id); // total by network
480481
++m_counts.at(2).at(m_networks_size); // total overall
481-
if (conn_type == "block-relay-only") {
482-
++m_counts.at(is_outbound).at(m_networks_size + 1); // in/out block-relay
483-
++m_counts.at(2).at(m_networks_size + 1); // total block-relay
484-
}
482+
if (conn_type == "block-relay-only") ++m_block_relay_peers_count;
485483
if (conn_type == "manual") ++m_manual_peers_count;
486484
if (DetailsRequested()) {
487485
// Push data for this peer to the peers vector.
@@ -553,8 +551,11 @@ class NetinfoRequestHandler : public BaseRequestHandler
553551
for (uint8_t i = 0; i < 3; ++i) {
554552
result += strprintf("\n%-5s %5i %5i %5i", rows.at(i), m_counts.at(i).at(0), m_counts.at(i).at(1), m_counts.at(i).at(2)); // ipv4/ipv6/onion peers counts
555553
if (m_is_i2p_on) result += strprintf(" %5i", m_counts.at(i).at(3)); // i2p peers count
556-
result += strprintf(" %5i %5i", m_counts.at(i).at(m_networks_size), m_counts.at(i).at(m_networks_size + 1));
557-
if (i == 1 && m_manual_peers_count) result += strprintf(" %5i", m_manual_peers_count);
554+
result += strprintf(" %5i", m_counts.at(i).at(m_networks_size)); // total peers count
555+
if (i == 1) { // the outbound row has two extra columns for block relay and manual peer counts
556+
result += strprintf(" %5i", m_block_relay_peers_count);
557+
if (m_manual_peers_count) result += strprintf(" %5i", m_manual_peers_count);
558+
}
558559
}
559560

560561
// Report local addresses, ports, and scores.

0 commit comments

Comments
 (0)