From 16a72ee3c5597a95878227d02f5481378e38d114 Mon Sep 17 00:00:00 2001 From: coderofstuff <114628839+coderofstuff@users.noreply.github.com> Date: Sun, 7 Jan 2024 00:12:11 -0700 Subject: [PATCH] Saturating sub for unknown tx limit --- protocol/flows/src/v5/txrelay/flow.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/flows/src/v5/txrelay/flow.rs b/protocol/flows/src/v5/txrelay/flow.rs index 88fb7b531..b4d86b441 100644 --- a/protocol/flows/src/v5/txrelay/flow.rs +++ b/protocol/flows/src/v5/txrelay/flow.rs @@ -146,7 +146,7 @@ impl RelayTransactionsFlow { let curr_p2p_tps = 1000 * snapshot_delta.low_priority_tx_counts / (snapshot_delta.elapsed_time.as_millis().max(1) as u64); let overage = if should_throttle && curr_p2p_tps > MAX_TPS_THRESHOLD { curr_p2p_tps - MAX_TPS_THRESHOLD } else { 0 }; - let limit = MAX_TPS_THRESHOLD - overage; + let limit = MAX_TPS_THRESHOLD.saturating_sub(overage); for transaction_id in transaction_ids { if let Some(req) = self.ctx.try_adding_transaction_request(transaction_id) {