mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
[rpc] Deprecate getpeerinfo addnode field
This field is now redundant since the connection type field will indicate MANUAL for addnode connections.
This commit is contained in:
parent
df091b9b50
commit
50f94b34a3
2 changed files with 19 additions and 2 deletions
|
@ -112,7 +112,8 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
|||
{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)"},
|
||||
|
@ -193,7 +194,10 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
|||
// 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")) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"""Test deprecation of getpeerinfo RPC fields."""
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import connect_nodes
|
||||
|
||||
|
||||
class GetpeerinfoDeprecationTest(BitcoinTestFramework):
|
||||
|
@ -14,6 +15,7 @@ class GetpeerinfoDeprecationTest(BitcoinTestFramework):
|
|||
|
||||
def run_test(self):
|
||||
self.test_banscore_deprecation()
|
||||
self.test_addnode_deprecation()
|
||||
|
||||
def test_banscore_deprecation(self):
|
||||
self.log.info("Test getpeerinfo by default no longer returns a banscore field")
|
||||
|
@ -22,5 +24,16 @@ class GetpeerinfoDeprecationTest(BitcoinTestFramework):
|
|||
self.log.info("Test getpeerinfo returns banscore with -deprecatedrpc=banscore")
|
||||
assert "banscore" in self.nodes[1].getpeerinfo()[0].keys()
|
||||
|
||||
def test_addnode_deprecation(self):
|
||||
self.restart_node(1, ["-deprecatedrpc=getpeerinfo_addnode"])
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
|
||||
self.log.info("Test getpeerinfo by default no longer returns an addnode field")
|
||||
assert "addnode" not in self.nodes[0].getpeerinfo()[0].keys()
|
||||
|
||||
self.log.info("Test getpeerinfo returns addnode with -deprecatedrpc=addnode")
|
||||
assert "addnode" in self.nodes[1].getpeerinfo()[0].keys()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
GetpeerinfoDeprecationTest().main()
|
||||
|
|
Loading…
Add table
Reference in a new issue