From a90f0bbb945f79056e743e7923f1ef120dca7fe2 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 6 Dec 2024 21:40:03 +0100 Subject: [PATCH] perf: call increment once --- crates/transaction-pool/src/pool/txpool.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/transaction-pool/src/pool/txpool.rs b/crates/transaction-pool/src/pool/txpool.rs index 1b330543cffa..2e37eec177d7 100644 --- a/crates/transaction-pool/src/pool/txpool.rs +++ b/crates/transaction-pool/src/pool/txpool.rs @@ -489,13 +489,16 @@ impl TxPool { self.all_transactions.set_block_info(block_info); // Remove all transaction that were included in the block + let mut removed_txs_count = 0; for tx_hash in &mined_transactions { if self.prune_transaction_by_hash(tx_hash).is_some() { - // Update removed transactions metric - self.metrics.removed_transactions.increment(1); + removed_txs_count += 1; } } + // Update removed transactions metric + self.metrics.removed_transactions.increment(removed_txs_count); + let UpdateOutcome { promoted, discarded } = self.update_accounts(changed_senders); self.update_transaction_type_metrics();