@@ -297,12 +297,12 @@ class NetinfoRequestHandler : public BaseRequestHandler
297297{
298298private:
299299 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 };
301301 const std::array<std::string, m_networks_size> m_networks{{" ipv4" , " ipv6" , " onion" }};
302302 std::array<std::array<uint16_t , m_networks_size + 2 >, 3 > m_counts{{{}}}; // !< Peer counts by (in/out/total, networks/total/block-relay)
303303 int8_t NetworkStringToId (const std::string& str) const
304304 {
305- for (size_t i = 0 ; i < m_networks_size; ++i) {
305+ for (uint8_t i = 0 ; i < m_networks_size; ++i) {
306306 if (str == m_networks.at (i)) return i;
307307 }
308308 return UNKNOWN_NETWORK;
@@ -315,19 +315,19 @@ class NetinfoRequestHandler : public BaseRequestHandler
315315 size_t m_max_addr_length{0 };
316316 size_t m_max_id_length{2 };
317317 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;
321323 int64_t conn_time;
322324 int64_t last_blck;
323325 int64_t last_recv;
324326 int64_t last_send;
325327 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;
331331 bool is_block_relay;
332332 bool is_outbound;
333333 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
336336 std::string ChainToString () const
337337 {
338338 if (gArgs .GetChainName () == CBaseChainParams::TESTNET) return " testnet" ;
339+ if (gArgs .GetChainName () == CBaseChainParams::SIGNET) return " signet" ;
339340 if (gArgs .GetChainName () == CBaseChainParams::REGTEST) return " regtest" ;
340341 return " " ;
341342 }
@@ -399,7 +400,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
399400 const double ping{peer[" pingtime" ].isNull () ? -1 : peer[" pingtime" ].get_real ()};
400401 const std::string addr{peer[" addr" ].get_str ()};
401402 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});
403404 m_max_id_length = std::max (ToString (peer_id).length (), m_max_id_length);
404405 m_max_addr_length = std::max (addr.length () + 1 , m_max_addr_length);
405406 m_is_asmap_on |= (mapped_as != 0 );
@@ -412,13 +413,13 @@ class NetinfoRequestHandler : public BaseRequestHandler
412413 // Report detailed peer connections list sorted by direction and minimum ping time.
413414 if (DetailsRequested () && !m_peers.empty ()) {
414415 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 " ;
416417 if (m_is_asmap_on) result += " asmap " ;
417418 result += strprintf (" %*s %-*s%s\n " , m_max_id_length, " id" , IsAddressSelected () ? m_max_addr_length : 0 , IsAddressSelected () ? " address" : " " , IsVersionSelected () ? " version" : " " );
418419 for (const Peer& peer : m_peers) {
419420 std::string version{ToString (peer.version ) + peer.sub_version };
420421 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 " ,
422423 peer.is_outbound ? " out" : " in" ,
423424 peer.is_block_relay ? " block" : " full" ,
424425 peer.network ,
@@ -437,13 +438,13 @@ class NetinfoRequestHandler : public BaseRequestHandler
437438 IsAddressSelected () ? peer.addr : " " ,
438439 IsVersionSelected () && version != " 0" ? version : " " );
439440 }
440- result += " ms ms sec sec min min min\n\n " ;
441+ result += " ms ms sec sec min min min\n\n " ;
441442 }
442443
443444 // Report peer connection totals by type.
444445 result += " ipv4 ipv6 onion total block-relay\n " ;
445446 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) {
447448 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 ));
448449 }
449450
0 commit comments