@@ -300,7 +300,6 @@ class NetinfoRequestHandler : public BaseRequestHandler
300
300
{
301
301
private:
302
302
static constexpr int8_t UNKNOWN_NETWORK{-1 };
303
- static constexpr int8_t NET_I2P{3 }; // pos of "i2p" in m_networks
304
303
static constexpr uint8_t m_networks_size{4 };
305
304
static constexpr uint8_t MAX_DETAIL_LEVEL{4 };
306
305
const std::array<std::string, m_networks_size> m_networks{{" ipv4" , " ipv6" , " onion" , " i2p" }};
@@ -319,7 +318,6 @@ class NetinfoRequestHandler : public BaseRequestHandler
319
318
bool IsAddressSelected () const { return m_details_level == 2 || m_details_level == 4 ; }
320
319
bool IsVersionSelected () const { return m_details_level == 3 || m_details_level == 4 ; }
321
320
bool m_is_asmap_on{false };
322
- bool m_is_i2p_on{false };
323
321
size_t m_max_addr_length{0 };
324
322
size_t m_max_age_length{3 };
325
323
size_t m_max_id_length{2 };
@@ -404,7 +402,6 @@ class NetinfoRequestHandler : public BaseRequestHandler
404
402
const std::string network{peer[" network" ].get_str ()};
405
403
const int8_t network_id{NetworkStringToId (network)};
406
404
if (network_id == UNKNOWN_NETWORK) continue ;
407
- m_is_i2p_on |= (network_id == NET_I2P);
408
405
const bool is_outbound{!peer[" inbound" ].get_bool ()};
409
406
const bool is_block_relay{!peer[" relaytxes" ].get_bool ()};
410
407
const std::string conn_type{peer[" connection_type" ].get_str ()};
@@ -477,13 +474,14 @@ class NetinfoRequestHandler : public BaseRequestHandler
477
474
478
475
// Report peer connection totals by type.
479
476
result += " ipv4 ipv6 onion" ;
480
- if (m_is_i2p_on) result += " i2p" ;
477
+ const bool any_i2p_peers = m_counts.at (2 ).at (3 ); // false if total i2p peers count is 0, otherwise true
478
+ if (any_i2p_peers) result += " i2p" ;
481
479
result += " total block" ;
482
480
if (m_manual_peers_count) result += " manual" ;
483
481
const std::array<std::string, 3 > rows{{" in" , " out" , " total" }};
484
482
for (uint8_t i = 0 ; i < 3 ; ++i) {
485
483
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
486
- if (m_is_i2p_on ) result += strprintf (" %5i" , m_counts.at (i).at (3 )); // i2p peers count
484
+ if (any_i2p_peers ) result += strprintf (" %5i" , m_counts.at (i).at (3 )); // i2p peers count
487
485
result += strprintf (" %5i" , m_counts.at (i).at (m_networks_size)); // total peers count
488
486
if (i == 1 ) { // the outbound row has two extra columns for block relay and manual peer counts
489
487
result += strprintf (" %5i" , m_block_relay_peers_count);
0 commit comments