Skip to content

Commit

Permalink
refactor(tx-pool): small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger committed Oct 26, 2024
1 parent ab07fcf commit a561125
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/maintain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ where
// Filter out errors
<P::Transaction as PoolTransaction>::try_from_consensus(tx.into()).ok()
})
.collect::<Vec<_>>();
.collect();

let outcome = pool.add_transactions(crate::TransactionOrigin::Local, pool_transactions).await;

Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/pool/best.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl<T: TransactionOrdering> Iterator for BestTransactions<T> {
}
}

/// A[`BestTransactions`](crate::traits::BestTransactions) implementation that filters the
/// A [`BestTransactions`](crate::traits::BestTransactions) implementation that filters the
/// transactions of iter with predicate.
///
/// Filter out transactions are marked as invalid:
Expand Down
15 changes: 7 additions & 8 deletions crates/transaction-pool/src/pool/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{

/// A set of validated blob transactions in the pool that are __not pending__.
///
/// The purpose of this pool is keep track of blob transactions that are queued and to evict the
/// The purpose of this pool is to keep track of blob transactions that are queued and to evict the
/// worst blob transactions once the sub-pool is full.
///
/// This expects that certain constraints are met:
Expand Down Expand Up @@ -198,14 +198,13 @@ impl<T: PoolTransaction> BlobTransactions<T> {
&mut self,
pending_fees: &PendingFees,
) -> Vec<Arc<ValidPoolTransaction<T>>> {
let to_remove = self.satisfy_pending_fee_ids(pending_fees);

let mut removed = Vec::with_capacity(to_remove.len());
for id in to_remove {
removed.push(self.remove_transaction(&id).expect("transaction exists"));
}
let removed = self
.satisfy_pending_fee_ids(pending_fees)
.into_iter()
.map(|id| self.remove_transaction(&id).expect("transaction exists"))
.collect();

// set pending fees and reprioritize / resort
// Update pending fees and reprioritize
self.pending_fees = pending_fees.clone();
self.reprioritize();

Expand Down

0 comments on commit a561125

Please sign in to comment.