@@ -400,12 +400,14 @@ class NetinfoRequestHandler : public BaseRequestHandler
400
400
size_t m_max_addr_rate_limited_length{6 };
401
401
size_t m_max_age_length{5 };
402
402
size_t m_max_id_length{2 };
403
+ size_t m_max_services_length{6 };
403
404
struct Peer {
404
405
std::string addr;
405
406
std::string sub_version;
406
407
std::string conn_type;
407
408
std::string network;
408
409
std::string age;
410
+ std::string services;
409
411
std::string transport_protocol_type;
410
412
double min_ping;
411
413
double ping;
@@ -456,6 +458,15 @@ class NetinfoRequestHandler : public BaseRequestHandler
456
458
if (conn_type == " addr-fetch" ) return " addr" ;
457
459
return " " ;
458
460
}
461
+ std::string FormatServices (const UniValue& services)
462
+ {
463
+ std::string str;
464
+ for (size_t i = 0 ; i < services.size (); ++i) {
465
+ const std::string s{services[i].get_str ()};
466
+ str += s == " NETWORK_LIMITED" ? ' l' : s == " P2P_V2" ? ' 2' : ToLower (s[0 ]);
467
+ }
468
+ return str;
469
+ }
459
470
460
471
public:
461
472
static constexpr int ID_PEERINFO = 0 ;
@@ -519,17 +530,19 @@ class NetinfoRequestHandler : public BaseRequestHandler
519
530
const double ping{peer[" pingtime" ].isNull () ? -1 : peer[" pingtime" ].get_real ()};
520
531
const std::string addr{peer[" addr" ].get_str ()};
521
532
const std::string age{conn_time == 0 ? " " : ToString ((time_now - conn_time) / 60 )};
533
+ const std::string services{FormatServices (peer[" servicesnames" ])};
522
534
const std::string sub_version{peer[" subver" ].get_str ()};
523
535
const std::string transport{peer[" transport_protocol_type" ].isNull () ? " v1" : peer[" transport_protocol_type" ].get_str ()};
524
536
const bool is_addr_relay_enabled{peer[" addr_relay_enabled" ].isNull () ? false : peer[" addr_relay_enabled" ].get_bool ()};
525
537
const bool is_bip152_hb_from{peer[" bip152_hb_from" ].get_bool ()};
526
538
const bool is_bip152_hb_to{peer[" bip152_hb_to" ].get_bool ()};
527
- m_peers.push_back ({addr, sub_version, conn_type, NETWORK_SHORT_NAMES[network_id], age, transport, min_ping, ping, addr_processed, addr_rate_limited, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version, is_addr_relay_enabled, is_bip152_hb_from, is_bip152_hb_to, is_outbound, is_tx_relay});
539
+ m_peers.push_back ({addr, sub_version, conn_type, NETWORK_SHORT_NAMES[network_id], age, services, transport, min_ping, ping, addr_processed, addr_rate_limited, last_blck, last_recv, last_send, last_trxn, peer_id, mapped_as, version, is_addr_relay_enabled, is_bip152_hb_from, is_bip152_hb_to, is_outbound, is_tx_relay});
528
540
m_max_addr_length = std::max (addr.length () + 1 , m_max_addr_length);
529
541
m_max_addr_processed_length = std::max (ToString (addr_processed).length (), m_max_addr_processed_length);
530
542
m_max_addr_rate_limited_length = std::max (ToString (addr_rate_limited).length (), m_max_addr_rate_limited_length);
531
543
m_max_age_length = std::max (age.length (), m_max_age_length);
532
544
m_max_id_length = std::max (ToString (peer_id).length (), m_max_id_length);
545
+ m_max_services_length = std::max (services.length (), m_max_services_length);
533
546
m_is_asmap_on |= (mapped_as != 0 );
534
547
}
535
548
}
@@ -540,7 +553,8 @@ class NetinfoRequestHandler : public BaseRequestHandler
540
553
// Report detailed peer connections list sorted by direction and minimum ping time.
541
554
if (DetailsRequested () && !m_peers.empty ()) {
542
555
std::sort (m_peers.begin (), m_peers.end ());
543
- result += strprintf (" <-> type net v mping ping send recv txn blk hb %*s%*s%*s " ,
556
+ result += strprintf (" <-> type net %*s v mping ping send recv txn blk hb %*s%*s%*s " ,
557
+ m_max_services_length, " serv" ,
544
558
m_max_addr_processed_length, " addrp" ,
545
559
m_max_addr_rate_limited_length, " addrl" ,
546
560
m_max_age_length, " age" );
@@ -549,10 +563,12 @@ class NetinfoRequestHandler : public BaseRequestHandler
549
563
for (const Peer& peer : m_peers) {
550
564
std::string version{ToString (peer.version ) + peer.sub_version };
551
565
result += strprintf (
552
- " %3s %6s %5s %2s%7s%7s%5s%5s%5s%5s %2s %*s%*s%*s%*i %*s %-*s%s\n " ,
566
+ " %3s %6s %5s %*s % 2s%7s%7s%5s%5s%5s%5s %2s %*s%*s%*s%*i %*s %-*s%s\n " ,
553
567
peer.is_outbound ? " out" : " in" ,
554
568
ConnectionTypeForNetinfo (peer.conn_type ),
555
569
peer.network ,
570
+ m_max_services_length, // variable spacing
571
+ peer.services ,
556
572
(peer.transport_protocol_type .size () == 2 && peer.transport_protocol_type [0 ] == ' v' ) ? peer.transport_protocol_type [1 ] : ' ' ,
557
573
PingTimeToString (peer.min_ping ),
558
574
PingTimeToString (peer.ping ),
@@ -575,7 +591,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
575
591
IsAddressSelected () ? peer.addr : " " ,
576
592
IsVersionSelected () && version != " 0" ? version : " " );
577
593
}
578
- result += strprintf (" ms ms sec sec min min %*s\n\n " , m_max_age_length, " min" );
594
+ result += strprintf (" %*s ms ms sec sec min min %*s\n\n " , m_max_services_length, " " , m_max_age_length, " min" );
579
595
}
580
596
581
597
// Report peer connection totals by type.
@@ -663,6 +679,14 @@ class NetinfoRequestHandler : public BaseRequestHandler
663
679
" \" feeler\" - short-lived connection for testing addresses\n "
664
680
" \" addr\" - address fetch; short-lived connection for requesting addresses\n "
665
681
" net Network the peer connected through (\" ipv4\" , \" ipv6\" , \" onion\" , \" i2p\" , \" cjdns\" , or \" npr\" (not publicly routable))\n "
682
+ " serv Services offered by the peer\n "
683
+ " \" n\" - NETWORK: peer can serve the full block chain\n "
684
+ " \" b\" - BLOOM: peer can handle bloom-filtered connections (see BIP 111)\n "
685
+ " \" w\" - WITNESS: peer can be asked for blocks and transactions with witness data (SegWit)\n "
686
+ " \" c\" - COMPACT_FILTERS: peer can handle basic block filter requests (see BIPs 157 and 158)\n "
687
+ " \" l\" - NETWORK_LIMITED: peer limited to serving only the last 288 blocks (~2 days)\n "
688
+ " \" 2\" - P2P_V2: peer supports version 2 P2P transport protocol, as defined in BIP 324\n "
689
+ " \" u\" - UNKNOWN: unrecognized bit flag\n "
666
690
" v Version of transport protocol used for the connection\n "
667
691
" mping Minimum observed ping time, in milliseconds (ms)\n "
668
692
" ping Last observed ping time, in milliseconds (ms)\n "
0 commit comments