@@ -297,12 +297,12 @@ class NetinfoRequestHandler : public BaseRequestHandler
297
297
{
298
298
private:
299
299
static constexpr int8_t UNKNOWN_NETWORK{-1 };
300
- static constexpr size_t m_networks_size{3 };
300
+ static constexpr uint8_t m_networks_size{3 };
301
301
const std::array<std::string, m_networks_size> m_networks{{" ipv4" , " ipv6" , " onion" }};
302
302
std::array<std::array<uint16_t , m_networks_size + 2 >, 3 > m_counts{{{}}}; // !< Peer counts by (in/out/total, networks/total/block-relay)
303
303
int8_t NetworkStringToId (const std::string& str) const
304
304
{
305
- for (size_t i = 0 ; i < m_networks_size; ++i) {
305
+ for (uint8_t i = 0 ; i < m_networks_size; ++i) {
306
306
if (str == m_networks.at (i)) return i;
307
307
}
308
308
return UNKNOWN_NETWORK;
@@ -315,19 +315,19 @@ class NetinfoRequestHandler : public BaseRequestHandler
315
315
size_t m_max_addr_length{0 };
316
316
size_t m_max_id_length{2 };
317
317
struct Peer {
318
- int id;
319
- int mapped_as;
320
- int version;
318
+ std::string addr;
319
+ std::string sub_version;
320
+ std::string network;
321
+ double min_ping;
322
+ double ping;
321
323
int64_t conn_time;
322
324
int64_t last_blck;
323
325
int64_t last_recv;
324
326
int64_t last_send;
325
327
int64_t last_trxn;
326
- double min_ping;
327
- double ping;
328
- std::string addr;
329
- std::string network;
330
- std::string sub_version;
328
+ int id;
329
+ int mapped_as;
330
+ int version;
331
331
bool is_block_relay;
332
332
bool is_outbound;
333
333
bool operator <(const Peer& rhs) const { return std::tie (is_outbound, min_ping) < std::tie (rhs.is_outbound , rhs.min_ping ); }
@@ -336,6 +336,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
336
336
std::string ChainToString () const
337
337
{
338
338
if (gArgs .GetChainName () == CBaseChainParams::TESTNET) return " testnet" ;
339
+ if (gArgs .GetChainName () == CBaseChainParams::SIGNET) return " signet" ;
339
340
if (gArgs .GetChainName () == CBaseChainParams::REGTEST) return " regtest" ;
340
341
return " " ;
341
342
}
@@ -399,7 +400,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
399
400
const double ping{peer[" pingtime" ].isNull () ? -1 : peer[" pingtime" ].get_real ()};
400
401
const std::string addr{peer[" addr" ].get_str ()};
401
402
const std::string sub_version{peer[" subver" ].get_str ()};
402
- m_peers.push_back ({peer_id, mapped_as, version, conn_time, last_blck, last_recv, last_send, last_trxn, min_ping, ping, addr, network, sub_version , is_block_relay, is_outbound});
403
+ m_peers.push_back ({addr, sub_version, network, min_ping, ping, conn_time, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version , is_block_relay, is_outbound});
403
404
m_max_id_length = std::max (ToString (peer_id).length (), m_max_id_length);
404
405
m_max_addr_length = std::max (addr.length () + 1 , m_max_addr_length);
405
406
m_is_asmap_on |= (mapped_as != 0 );
@@ -412,13 +413,13 @@ class NetinfoRequestHandler : public BaseRequestHandler
412
413
// Report detailed peer connections list sorted by direction and minimum ping time.
413
414
if (DetailsRequested () && !m_peers.empty ()) {
414
415
std::sort (m_peers.begin (), m_peers.end ());
415
- result += " Peer connections sorted by direction and min ping\n <-> relay net mping ping send recv txn blk uptime " ;
416
+ result += " Peer connections sorted by direction and min ping\n <-> relay net mping ping send recv txn blk age " ;
416
417
if (m_is_asmap_on) result += " asmap " ;
417
418
result += strprintf (" %*s %-*s%s\n " , m_max_id_length, " id" , IsAddressSelected () ? m_max_addr_length : 0 , IsAddressSelected () ? " address" : " " , IsVersionSelected () ? " version" : " " );
418
419
for (const Peer& peer : m_peers) {
419
420
std::string version{ToString (peer.version ) + peer.sub_version };
420
421
result += strprintf (
421
- " %3s %5s %5s%6s %7s%5s%5s%5s%5s%7s%*i %*s %-*s%s\n " ,
422
+ " %3s %5s %5s%7s %7s%5s%5s%5s%5s%7s%*i %*s %-*s%s\n " ,
422
423
peer.is_outbound ? " out" : " in" ,
423
424
peer.is_block_relay ? " block" : " full" ,
424
425
peer.network ,
@@ -437,13 +438,13 @@ class NetinfoRequestHandler : public BaseRequestHandler
437
438
IsAddressSelected () ? peer.addr : " " ,
438
439
IsVersionSelected () && version != " 0" ? version : " " );
439
440
}
440
- result += " ms ms sec sec min min min\n\n " ;
441
+ result += " ms ms sec sec min min min\n\n " ;
441
442
}
442
443
443
444
// Report peer connection totals by type.
444
445
result += " ipv4 ipv6 onion total block-relay\n " ;
445
446
const std::array<std::string, 3 > rows{{" in" , " out" , " total" }};
446
- for (size_t i = 0 ; i < m_networks_size; ++i) {
447
+ for (uint8_t i = 0 ; i < m_networks_size; ++i) {
447
448
result += strprintf (" %-5s %5i %5i %5i %5i %5i\n " , rows.at (i), m_counts.at (i).at (0 ), m_counts.at (i).at (1 ), m_counts.at (i).at (2 ), m_counts.at (i).at (m_networks_size), m_counts.at (i).at (m_networks_size + 1 ));
448
449
}
449
450
0 commit comments