rpc: define and use new RPC_LIMIT_EXCEEDED error code

The server isn't running out of memory when the private broadcast
transaction queue is full. Add a new RPC_LIMIT_EXCEEDED code that
can be used whenever a resource is bound and currently at capacity.

Github-Pull: #35678
Rebased-From: 82a02a2a22
This commit is contained in:
stickies-v
2026-07-07 16:18:41 +01:00
committed by fanquake
parent cd32ebd3f4
commit ec1123aed1
3 changed files with 3 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ enum RPCErrorCode
RPC_VERIFY_ALREADY_IN_UTXO_SET = -27, //!< Transaction already in utxo set
RPC_IN_WARMUP = -28, //!< Client still warming up
RPC_METHOD_DEPRECATED = -32, //!< RPC method is deprecated
RPC_LIMIT_EXCEEDED = -37, //!< A bounded resource is currently at capacity
//! Aliases for backward compatibility
RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR,

View File

@@ -396,7 +396,7 @@ RPCErrorCode RPCErrorFromTransactionError(TransactionError terr)
case TransactionError::ALREADY_IN_UTXO_SET:
return RPC_VERIFY_ALREADY_IN_UTXO_SET;
case TransactionError::PRIVATE_BROADCAST_FULL:
return RPC_OUT_OF_MEMORY;
return RPC_LIMIT_EXCEEDED;
default: break;
}
return RPC_TRANSACTION_ERROR;

View File

@@ -71,7 +71,7 @@ class PrivateBroadcastCapTest(BitcoinTestFramework):
# queue is left unchanged (nothing evicted to make room).
self.log.info(f"Submitting {OVER_CAP} more; each should be rejected (queue full)")
for child in children[MAX_TRANSACTIONS:]:
assert_raises_rpc_error(-7, "Private broadcast queue is full",
assert_raises_rpc_error(-37, "Private broadcast queue is full",
node.sendrawtransaction, child["hex"])
assert_equal(pbinfo["transactions"], node.getprivatebroadcastinfo()["transactions"])