Skip to content

Commit 82a02a2

Browse files
committed
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.
1 parent a64df33 commit 82a02a2

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/rpc/protocol.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ enum RPCErrorCode
7272
RPC_VERIFY_ALREADY_IN_UTXO_SET = -27, //!< Transaction already in utxo set
7373
RPC_IN_WARMUP = -28, //!< Client still warming up
7474
RPC_METHOD_DEPRECATED = -32, //!< RPC method is deprecated
75+
RPC_LIMIT_EXCEEDED = -37, //!< A bounded resource is currently at capacity
7576

7677
//! Aliases for backward compatibility
7778
RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR,

‎src/rpc/util.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ RPCErrorCode RPCErrorFromTransactionError(TransactionError terr)
396396
case TransactionError::ALREADY_IN_UTXO_SET:
397397
return RPC_VERIFY_ALREADY_IN_UTXO_SET;
398398
case TransactionError::PRIVATE_BROADCAST_FULL:
399-
return RPC_OUT_OF_MEMORY;
399+
return RPC_LIMIT_EXCEEDED;
400400
default: break;
401401
}
402402
return RPC_TRANSACTION_ERROR;

‎test/functional/p2p_private_broadcast_cap.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def run_test(self):
7171
# queue is left unchanged (nothing evicted to make room).
7272
self.log.info(f"Submitting {OVER_CAP} more; each should be rejected (queue full)")
7373
for child in children[MAX_TRANSACTIONS:]:
74-
assert_raises_rpc_error(-7, "Private broadcast queue is full",
74+
assert_raises_rpc_error(-37, "Private broadcast queue is full",
7575
node.sendrawtransaction, child["hex"])
7676

7777
assert_equal(pbinfo["transactions"], node.getprivatebroadcastinfo()["transactions"])

0 commit comments

Comments
 (0)