0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

net: make CConnMan::AddConnection return success

Return the status of `AddConnection()` to the `addconnection()` RPC.

Also rename RPCErrorCode 34 to align with the behaviour it signifies.

Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
This commit is contained in:
willcl-ark 2024-07-02 16:22:29 +01:00
parent cb3f784e54
commit 53e5882a86
No known key found for this signature in database
GPG key ID: CE6EC49945C17EA6
3 changed files with 3 additions and 4 deletions

View file

@ -1855,8 +1855,7 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ
CSemaphoreGrant grant(*semOutbound, true); CSemaphoreGrant grant(*semOutbound, true);
if (!grant) return false; if (!grant) return false;
OpenNetworkConnection(CAddress(), false, std::move(grant), address.c_str(), conn_type, /*use_v2transport=*/use_v2transport); return OpenNetworkConnection(CAddress(), false, std::move(grant), address.c_str(), conn_type, /*use_v2transport=*/use_v2transport);
return true;
} }
void CConnman::DisconnectNodes() void CConnman::DisconnectNodes()

View file

@ -415,7 +415,7 @@ static RPCHelpMan addconnection()
const bool success = connman.AddConnection(address, conn_type, use_v2transport); const bool success = connman.AddConnection(address, conn_type, use_v2transport);
if (!success) { if (!success) {
throw JSONRPCError(RPC_CLIENT_NODE_CAPACITY_REACHED, "Error: Already at capacity for specified connection type."); throw JSONRPCError(RPC_CLIENT_PEER_NOT_CONNECTED, "Error: Unable to open connection");
} }
UniValue info(UniValue::VOBJ); UniValue info(UniValue::VOBJ);

View file

@ -63,7 +63,7 @@ enum RPCErrorCode
RPC_CLIENT_NODE_NOT_CONNECTED = -29, //!< Node to disconnect not found in connected nodes RPC_CLIENT_NODE_NOT_CONNECTED = -29, //!< Node to disconnect not found in connected nodes
RPC_CLIENT_INVALID_IP_OR_SUBNET = -30, //!< Invalid IP/Subnet RPC_CLIENT_INVALID_IP_OR_SUBNET = -30, //!< Invalid IP/Subnet
RPC_CLIENT_P2P_DISABLED = -31, //!< No valid connection manager instance found RPC_CLIENT_P2P_DISABLED = -31, //!< No valid connection manager instance found
RPC_CLIENT_NODE_CAPACITY_REACHED= -34, //!< Max number of outbound or block-relay connections already open RPC_CLIENT_PEER_NOT_CONNECTED = -34, //!< We were unable to open a new connection to this peer
//! Chain errors //! Chain errors
RPC_CLIENT_MEMPOOL_DISABLED = -33, //!< No mempool instance found RPC_CLIENT_MEMPOOL_DISABLED = -33, //!< No mempool instance found