Skip to content

Commit

Permalink
Saturating sub for unknown tx limit
Browse files Browse the repository at this point in the history
  • Loading branch information
coderofstuff committed Jan 7, 2024
1 parent 77b1952 commit 16a72ee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion protocol/flows/src/v5/txrelay/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 16a72ee

Please sign in to comment.