Skip to content

Commit

Permalink
perf: prevent changed senders clone
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Dec 6, 2024
1 parent c608679 commit 5348774
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,12 @@ impl<T: TransactionOrdering> TxPool<T> {
&mut self,
changed_senders: HashMap<SenderId, SenderInfo>,
) -> UpdateOutcome<T::Transaction> {
// track changed accounts
self.sender_info.extend(changed_senders.clone());
// Apply the state changes to the total set of transactions which triggers sub-pool updates.
let updates = self.all_transactions.update(changed_senders);
let updates = self.all_transactions.update(&changed_senders);

// track changed accounts
self.sender_info.extend(changed_senders);

// Process the sub-pool updates
let update = self.process_updates(updates);
// update the metrics after the update
Expand Down Expand Up @@ -1180,7 +1182,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
/// that got transaction included in the block.
pub(crate) fn update(
&mut self,
changed_accounts: HashMap<SenderId, SenderInfo>,
changed_accounts: &HashMap<SenderId, SenderInfo>,
) -> Vec<PoolUpdate> {
// pre-allocate a few updates
let mut updates = Vec::with_capacity(64);
Expand Down

0 comments on commit 5348774

Please sign in to comment.