Skip to content

Commit

Permalink
chore: simplify update fn (#11880)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Oct 18, 2024
1 parent 587c91f commit a908f97
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions crates/transaction-pool/src/pool/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<T: TransactionOrdering> PendingPool<T> {
}
} else {
self.size_of += tx.transaction.size();
self.update_independents_and_highest_nonces(&tx, &id);
self.update_independents_and_highest_nonces(&tx);
self.all.insert(tx.clone());
self.by_id.insert(id, tx);
}
Expand Down Expand Up @@ -243,7 +243,7 @@ impl<T: TransactionOrdering> PendingPool<T> {
tx.priority = self.ordering.priority(&tx.transaction.transaction, base_fee);

self.size_of += tx.transaction.size();
self.update_independents_and_highest_nonces(&tx, &id);
self.update_independents_and_highest_nonces(&tx);
self.all.insert(tx.clone());
self.by_id.insert(id, tx);
}
Expand All @@ -254,12 +254,8 @@ impl<T: TransactionOrdering> PendingPool<T> {

/// Updates the independent transaction and highest nonces set, assuming the given transaction
/// is being _added_ to the pool.
fn update_independents_and_highest_nonces(
&mut self,
tx: &PendingTransaction<T>,
tx_id: &TransactionId,
) {
let ancestor_id = tx_id.unchecked_ancestor();
fn update_independents_and_highest_nonces(&mut self, tx: &PendingTransaction<T>) {
let ancestor_id = tx.transaction.id().unchecked_ancestor();
if let Some(ancestor) = ancestor_id.and_then(|id| self.by_id.get(&id)) {
// the transaction already has an ancestor, so we only need to ensure that the
// highest nonces set actually contains the highest nonce for that sender
Expand Down Expand Up @@ -305,7 +301,7 @@ impl<T: TransactionOrdering> PendingPool<T> {
let priority = self.ordering.priority(&tx.transaction, base_fee);
let tx = PendingTransaction { submission_id, transaction: tx, priority };

self.update_independents_and_highest_nonces(&tx, &tx_id);
self.update_independents_and_highest_nonces(&tx);
self.all.insert(tx.clone());

// send the new transaction to any existing pendingpool static file iterators
Expand Down

0 comments on commit a908f97

Please sign in to comment.