mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
txpool: added a helper to filter pending txns by predicate (#12204)
This commit is contained in:
committed by
GitHub
parent
249c600dd9
commit
2758a560c0
@ -496,6 +496,13 @@ where
|
||||
self.pool.get_transactions_by_sender(sender)
|
||||
}
|
||||
|
||||
fn get_pending_transactions_with_predicate(
|
||||
&self,
|
||||
predicate: impl FnMut(&ValidPoolTransaction<Self::Transaction>) -> bool,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
self.pool.pending_transactions_with_predicate(predicate)
|
||||
}
|
||||
|
||||
fn get_pending_transactions_by_sender(
|
||||
&self,
|
||||
sender: Address,
|
||||
|
||||
@ -213,6 +213,13 @@ impl TransactionPool for NoopTransactionPool {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn get_pending_transactions_with_predicate(
|
||||
&self,
|
||||
_predicate: impl FnMut(&ValidPoolTransaction<Self::Transaction>) -> bool,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn get_pending_transactions_by_sender(
|
||||
&self,
|
||||
_sender: Address,
|
||||
|
||||
@ -787,6 +787,14 @@ where
|
||||
self.get_pool_data().pending_txs_by_sender(sender_id)
|
||||
}
|
||||
|
||||
/// Returns all pending transactions filtered by predicate
|
||||
pub(crate) fn pending_transactions_with_predicate(
|
||||
&self,
|
||||
predicate: impl FnMut(&ValidPoolTransaction<T::Transaction>) -> bool,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
self.get_pool_data().pending_transactions_with_predicate(predicate)
|
||||
}
|
||||
|
||||
/// Returns all pending transactions of the address by sender
|
||||
pub(crate) fn get_pending_transactions_by_sender(
|
||||
&self,
|
||||
|
||||
@ -364,6 +364,14 @@ impl<T: TransactionOrdering> TxPool<T> {
|
||||
self.pending_pool.all()
|
||||
}
|
||||
|
||||
/// Returns all pending transactions filtered by predicate
|
||||
pub(crate) fn pending_transactions_with_predicate(
|
||||
&self,
|
||||
mut predicate: impl FnMut(&ValidPoolTransaction<T::Transaction>) -> bool,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
self.pending_transactions_iter().filter(|tx| predicate(tx)).collect()
|
||||
}
|
||||
|
||||
/// Returns all pending transactions for the specified sender
|
||||
pub(crate) fn pending_txs_by_sender(
|
||||
&self,
|
||||
|
||||
@ -342,6 +342,12 @@ pub trait TransactionPool: Send + Sync + Clone {
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns all pending transactions filtered by predicate
|
||||
fn get_pending_transactions_with_predicate(
|
||||
&self,
|
||||
predicate: impl FnMut(&ValidPoolTransaction<Self::Transaction>) -> bool,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns all pending transactions sent by a given user
|
||||
fn get_pending_transactions_by_sender(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user