mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
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:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user