merge bitcoin#29239: Make v2transport default for addnode RPC when enabled

This commit is contained in:
Kittywhiskers Van Gogh 2024-01-11 16:27:32 -05:00
parent b2ac426a24
commit 5dd60c4875
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 7 additions and 6 deletions

View File

@ -311,7 +311,7 @@ static RPCHelpMan addnode()
{ {
{"node", RPCArg::Type::STR, RPCArg::Optional::NO, "The node (see getpeerinfo for nodes)"}, {"node", RPCArg::Type::STR, RPCArg::Optional::NO, "The node (see getpeerinfo for nodes)"},
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once"}, {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once"},
{"v2transport", RPCArg::Type::BOOL, RPCArg::Default{false}, "Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command)"}, {"v2transport", RPCArg::Type::BOOL, RPCArg::DefaultHint{"set by -v2transport"}, "Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command)"},
}, },
RPCResult{RPCResult::Type::NONE, "", ""}, RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{ RPCExamples{
@ -332,9 +332,10 @@ static RPCHelpMan addnode()
CConnman& connman = EnsureConnman(node); CConnman& connman = EnsureConnman(node);
std::string strNode = request.params[0].get_str(); std::string strNode = request.params[0].get_str();
bool use_v2transport = request.params[2].isNull() ? false : request.params[2].get_bool(); bool node_v2transport = connman.GetLocalServices() & NODE_P2P_V2;
bool use_v2transport = request.params[2].isNull() ? node_v2transport : request.params[2].get_bool();
if (use_v2transport && !(node.connman->GetLocalServices() & NODE_P2P_V2)) { if (use_v2transport && !node_v2transport) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Error: v2transport requested but not enabled (see -v2transport)"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Error: v2transport requested but not enabled (see -v2transport)");
} }

View File

@ -707,10 +707,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
if peer_advertises_v2 is None: if peer_advertises_v2 is None:
peer_advertises_v2 = from_connection.use_v2transport peer_advertises_v2 = from_connection.use_v2transport
if peer_advertises_v2: if peer_advertises_v2 != from_connection.use_v2transport:
from_connection.addnode(node=ip_port, command="onetry", v2transport=True) from_connection.addnode(node=ip_port, command="onetry", v2transport=peer_advertises_v2)
else: else:
# skip the optional third argument (default false) for # skip the optional third argument if it matches the default, for
# compatibility with older clients # compatibility with older clients
from_connection.addnode(ip_port, "onetry") from_connection.addnode(ip_port, "onetry")