refactor(tx-pool): small refactor (#12107)

This commit is contained in:
Thomas Coratger
2024-10-27 02:59:57 +01:00
committed by GitHub
parent 988c5ee4c5
commit 8eb1742284
3 changed files with 9 additions and 10 deletions

View File

@@ -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;

View File

@@ -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:

View File

@@ -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:
@@ -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 removed = self
.satisfy_pending_fee_ids(pending_fees)
.into_iter()
.map(|id| self.remove_transaction(&id).expect("transaction exists"))
.collect();
let mut removed = Vec::with_capacity(to_remove.len());
for id in to_remove {
removed.push(self.remove_transaction(&id).expect("transaction exists"));
}
// set pending fees and reprioritize / resort
// Update pending fees and reprioritize
self.pending_fees = pending_fees.clone();
self.reprioritize();