mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-07 10:27:47 -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:
parent
cb3f784e54
commit
53e5882a86
3 changed files with 3 additions and 4 deletions
|
@ -1855,8 +1855,7 @@ bool CConnman::AddConnection(const std::string& address, ConnectionType conn_typ
|
|||
CSemaphoreGrant grant(*semOutbound, true);
|
||||
if (!grant) return false;
|
||||
|
||||
OpenNetworkConnection(CAddress(), false, std::move(grant), address.c_str(), conn_type, /*use_v2transport=*/use_v2transport);
|
||||
return true;
|
||||
return OpenNetworkConnection(CAddress(), false, std::move(grant), address.c_str(), conn_type, /*use_v2transport=*/use_v2transport);
|
||||
}
|
||||
|
||||
void CConnman::DisconnectNodes()
|
||||
|
|
|
@ -415,7 +415,7 @@ static RPCHelpMan addconnection()
|
|||
|
||||
const bool success = connman.AddConnection(address, conn_type, use_v2transport);
|
||||
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);
|
||||
|
|
|
@ -63,7 +63,7 @@ enum RPCErrorCode
|
|||
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_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
|
||||
RPC_CLIENT_MEMPOOL_DISABLED = -33, //!< No mempool instance found
|
||||
|
|
Loading…
Add table
Reference in a new issue