@@ -234,11 +234,10 @@ class BaseRequestHandler
234
234
class AddrinfoRequestHandler : public BaseRequestHandler
235
235
{
236
236
private:
237
- static constexpr uint8_t m_networks_size{5 };
238
- const std::array<std::string, m_networks_size> m_networks{{" ipv4" , " ipv6" , " torv2" , " torv3" , " i2p" }};
237
+ static constexpr std::array m_networks{" ipv4" , " ipv6" , " torv2" , " torv3" , " i2p" };
239
238
int8_t NetworkStringToId (const std::string& str) const
240
239
{
241
- for (uint8_t i = 0 ; i < m_networks_size ; ++i) {
240
+ for (size_t i = 0 ; i < m_networks. size () ; ++i) {
242
241
if (str == m_networks.at (i)) return i;
243
242
}
244
243
return UNKNOWN_NETWORK;
@@ -262,7 +261,7 @@ class AddrinfoRequestHandler : public BaseRequestHandler
262
261
throw std::runtime_error (" -addrinfo requires bitcoind server to be running v22.0 and up" );
263
262
}
264
263
// Count the number of peers we know by network, including torv2 versus torv3.
265
- std::array<uint64_t , m_networks_size > counts{{}};
264
+ std::array<uint64_t , m_networks. size () > counts{{}};
266
265
for (const UniValue& node : nodes) {
267
266
std::string network_name{node[" network" ].get_str ()};
268
267
if (network_name == " onion" ) {
@@ -275,7 +274,7 @@ class AddrinfoRequestHandler : public BaseRequestHandler
275
274
// Prepare result to return to user.
276
275
UniValue result{UniValue::VOBJ}, addresses{UniValue::VOBJ};
277
276
uint64_t total{0 }; // Total address count
278
- for (uint8_t i = 0 ; i < m_networks_size ; ++i) {
277
+ for (size_t i = 0 ; i < m_networks. size () ; ++i) {
279
278
addresses.pushKV (m_networks.at (i), counts.at (i));
280
279
total += counts.at (i);
281
280
}
@@ -356,15 +355,14 @@ class GetinfoRequestHandler: public BaseRequestHandler
356
355
class NetinfoRequestHandler : public BaseRequestHandler
357
356
{
358
357
private:
359
- static constexpr uint8_t m_networks_size{4 };
360
358
static constexpr uint8_t MAX_DETAIL_LEVEL{4 };
361
- const std::array<std::string, m_networks_size> m_networks{{ " ipv4" , " ipv6" , " onion" , " i2p" } };
362
- std::array<std::array<uint16_t , m_networks_size + 1 >, 3 > m_counts{{{}}}; // !< Peer counts by (in/out/total, networks/total)
359
+ static constexpr std::array m_networks{" ipv4" , " ipv6" , " onion" , " i2p" };
360
+ std::array<std::array<uint16_t , m_networks.size() + 1 >, 3 > m_counts{{{}}}; // !< Peer counts by (in/out/total, networks/total)
363
361
uint8_t m_block_relay_peers_count{0 };
364
362
uint8_t m_manual_peers_count{0 };
365
363
int8_t NetworkStringToId (const std::string& str) const
366
364
{
367
- for (uint8_t i = 0 ; i < m_networks_size ; ++i) {
365
+ for (size_t i = 0 ; i < m_networks. size () ; ++i) {
368
366
if (str == m_networks.at (i)) return i;
369
367
}
370
368
return UNKNOWN_NETWORK;
@@ -461,10 +459,10 @@ class NetinfoRequestHandler : public BaseRequestHandler
461
459
const bool is_outbound{!peer[" inbound" ].get_bool ()};
462
460
const bool is_block_relay{!peer[" relaytxes" ].get_bool ()};
463
461
const std::string conn_type{peer[" connection_type" ].get_str ()};
464
- ++m_counts.at (is_outbound).at (network_id); // in/out by network
465
- ++m_counts.at (is_outbound).at (m_networks_size ); // in/out overall
466
- ++m_counts.at (2 ).at (network_id); // total by network
467
- ++m_counts.at (2 ).at (m_networks_size ); // total overall
462
+ ++m_counts.at (is_outbound).at (network_id); // in/out by network
463
+ ++m_counts.at (is_outbound).at (m_networks. size () ); // in/out overall
464
+ ++m_counts.at (2 ).at (network_id); // total by network
465
+ ++m_counts.at (2 ).at (m_networks. size () ); // total overall
468
466
if (conn_type == " block-relay-only" ) ++m_block_relay_peers_count;
469
467
if (conn_type == " manual" ) ++m_manual_peers_count;
470
468
if (DetailsRequested ()) {
@@ -534,11 +532,11 @@ class NetinfoRequestHandler : public BaseRequestHandler
534
532
if (any_i2p_peers) result += " i2p" ;
535
533
result += " total block" ;
536
534
if (m_manual_peers_count) result += " manual" ;
537
- const std::array<std::string, 3 > rows{{ " in" , " out" , " total" } };
535
+ const std::array rows{" in" , " out" , " total" };
538
536
for (uint8_t i = 0 ; i < 3 ; ++i) {
539
537
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
540
538
if (any_i2p_peers) result += strprintf (" %5i" , m_counts.at (i).at (3 )); // i2p peers count
541
- result += strprintf (" %5i" , m_counts.at (i).at (m_networks_size )); // total peers count
539
+ result += strprintf (" %5i" , m_counts.at (i).at (m_networks. size () )); // total peers count
542
540
if (i == 1 ) { // the outbound row has two extra columns for block relay and manual peer counts
543
541
result += strprintf (" %5i" , m_block_relay_peers_count);
544
542
if (m_manual_peers_count) result += strprintf (" %5i" , m_manual_peers_count);
0 commit comments