mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Merge #19725: [RPC] Add connection type to getpeerinfo, improve logs
a512925e19[doc] Release notes (Amiti Uttarwar)50f94b34a3[rpc] Deprecate getpeerinfo addnode field (Amiti Uttarwar)df091b9b50[refactor] Rename test file to allow any getpeerinfo deprecations. (Amiti Uttarwar)395acfa83a[rpc] Add connection type to getpeerinfo RPC, update tests (Amiti Uttarwar)49c10a9ca4[log] Add connection type to log statement (Amiti Uttarwar) Pull request description: After #19316, we can more directly expose information about the connection type on the `getpeerinfo` RPC. Doing so also makes the existing addnode field redundant, so this PR begins the process of deprecating this field. This PR also includes one commit that improves a log message, as both use a shared function to return the connection type as a string. Suggested by sdaftuar- https://github.com/bitcoin/bitcoin/pull/19316#discussion_r468001604 & https://github.com/bitcoin/bitcoin/pull/19316#discussion_r468018093 ACKs for top commit: jnewbery: Code review ACKa512925e19. sipa: utACKa512925e19guggero: Tested and code review ACKa512925e. MarcoFalke: cr ACKa512925e19🌇 promag: Code review ACKa512925e19. Tree-SHA512: 601a7a38aee235ee59aca690784f886dc2ae4e418b2e6422c4b58cd597376c00f74910f66920b08a08a0bec28bf8022e71a1435785ff6ba8a188954261aba78e
This commit is contained in:
@@ -116,7 +116,9 @@ static RPCHelpMan getpeerinfo()
|
||||
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
|
||||
{RPCResult::Type::STR, "subver", "The string version"},
|
||||
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
|
||||
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection"},
|
||||
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n"
|
||||
"(DEPRECATED, returned only if the config option -deprecatedrpc=getpeerinfo_addnode is passed)"},
|
||||
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + "."},
|
||||
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
|
||||
{RPCResult::Type::NUM, "banscore", "The ban score (DEPRECATED, returned only if config option -deprecatedrpc=banscore is passed)"},
|
||||
{RPCResult::Type::NUM, "synced_headers", "The last header we have in common with this peer"},
|
||||
@@ -196,7 +198,10 @@ static RPCHelpMan getpeerinfo()
|
||||
// their ver message.
|
||||
obj.pushKV("subver", stats.cleanSubVer);
|
||||
obj.pushKV("inbound", stats.fInbound);
|
||||
obj.pushKV("addnode", stats.m_manual_connection);
|
||||
if (IsDeprecatedRPCEnabled("getpeerinfo_addnode")) {
|
||||
// addnode is deprecated in v0.21 for removal in v0.22
|
||||
obj.pushKV("addnode", stats.m_manual_connection);
|
||||
}
|
||||
obj.pushKV("startingheight", stats.nStartingHeight);
|
||||
if (fStateStats) {
|
||||
if (IsDeprecatedRPCEnabled("banscore")) {
|
||||
@@ -232,6 +237,7 @@ static RPCHelpMan getpeerinfo()
|
||||
recvPerMsgCmd.pushKV(i.first, i.second);
|
||||
}
|
||||
obj.pushKV("bytesrecv_per_msg", recvPerMsgCmd);
|
||||
obj.pushKV("connection_type", stats.m_conn_type_string);
|
||||
|
||||
ret.push_back(obj);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user