mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-22 21:50:14 +01:00
Merge #20002: net, rpc, cli: expose peer network in getpeerinfo; simplify/improve -netinfo
6272604befrefactor: enable -netinfo to add future networks (i2p, cjdns) (Jon Atack)82fd40216crefactor: promote some -netinfo localvars to class members (Jon Atack)5133fab37ecli: simplify -netinfo using getpeerinfo network field (Jon Atack)4938a109adrpc, test: expose CNodeStats network in RPC getpeerinfo (Jon Atack)6df7882029net: add peer network to CNodeStats (Jon Atack) Pull request description: This PR: - builds on #19991 and #19998 - exposes peer networks via a new getpeerinfo `network` field ("ipv4", "ipv6", or "onion"), and adds functional tests - updates -netinfo to use getpeerinfo `network` rather than detecting the peer networks client-side - refactors -netinfo to easily add future networks ACKs for top commit: laanwj: ACK6272604befTree-SHA512: 28883487585135ceaaf84ce09131f2336e3193407f2e3df0960e3f4ac340f500ab94ffecb9d06a4c49bc05e3cca4f914ea4379860bea0bd5df2f834f74616015
This commit is contained in:
@@ -94,6 +94,7 @@ static RPCHelpMan getpeerinfo()
|
||||
{RPCResult::Type::STR, "addr", "(host:port) The IP address and port of the peer"},
|
||||
{RPCResult::Type::STR, "addrbind", "(ip:port) Bind address of the connection to the peer"},
|
||||
{RPCResult::Type::STR, "addrlocal", "(ip:port) Local address as reported by the peer"},
|
||||
{RPCResult::Type::STR, "network", "Network (ipv4, ipv6, or onion) the peer connected through"},
|
||||
{RPCResult::Type::NUM, "mapped_as", "The AS in the BGP route to the peer used for diversifying\n"
|
||||
"peer selection (only available if the asmap config flag is set)"},
|
||||
{RPCResult::Type::STR_HEX, "services", "The services offered"},
|
||||
@@ -167,10 +168,13 @@ static RPCHelpMan getpeerinfo()
|
||||
bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
|
||||
obj.pushKV("id", stats.nodeid);
|
||||
obj.pushKV("addr", stats.addrName);
|
||||
if (!(stats.addrLocal.empty()))
|
||||
obj.pushKV("addrlocal", stats.addrLocal);
|
||||
if (stats.addrBind.IsValid())
|
||||
if (stats.addrBind.IsValid()) {
|
||||
obj.pushKV("addrbind", stats.addrBind.ToString());
|
||||
}
|
||||
if (!(stats.addrLocal.empty())) {
|
||||
obj.pushKV("addrlocal", stats.addrLocal);
|
||||
}
|
||||
obj.pushKV("network", stats.m_network);
|
||||
if (stats.m_mapped_as != 0) {
|
||||
obj.pushKV("mapped_as", uint64_t(stats.m_mapped_as));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user