mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
perf(AllTransactions-iter): do not clone all transactions by default (#13187)
This commit is contained in:
@ -295,7 +295,7 @@ where
|
||||
|
||||
/// Returns _all_ transactions in the pool.
|
||||
pub fn pooled_transactions(&self) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
self.get_pool_data().all().transactions_iter().filter(|tx| tx.propagate).collect()
|
||||
self.get_pool_data().all().transactions_iter().filter(|tx| tx.propagate).cloned().collect()
|
||||
}
|
||||
|
||||
/// Returns only the first `max` transactions in the pool.
|
||||
@ -303,7 +303,13 @@ where
|
||||
&self,
|
||||
max: usize,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
self.get_pool_data().all().transactions_iter().filter(|tx| tx.propagate).take(max).collect()
|
||||
self.get_pool_data()
|
||||
.all()
|
||||
.transactions_iter()
|
||||
.filter(|tx| tx.propagate)
|
||||
.take(max)
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Converts the internally tracked transaction to the pooled format.
|
||||
@ -857,7 +863,12 @@ where
|
||||
&self,
|
||||
origin: TransactionOrigin,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
self.get_pool_data().all().transactions_iter().filter(|tx| tx.origin == origin).collect()
|
||||
self.get_pool_data()
|
||||
.all()
|
||||
.transactions_iter()
|
||||
.filter(|tx| tx.origin == origin)
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns all pending transactions filted by [`TransactionOrigin`]
|
||||
|
||||
@ -1095,11 +1095,11 @@ impl<T: PoolTransaction> AllTransactions<T> {
|
||||
self.by_hash.keys().copied()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all _unique_ hashes in the pool
|
||||
/// Returns an iterator over all transactions in the pool
|
||||
pub(crate) fn transactions_iter(
|
||||
&self,
|
||||
) -> impl Iterator<Item = Arc<ValidPoolTransaction<T>>> + '_ {
|
||||
self.by_hash.values().cloned()
|
||||
) -> impl Iterator<Item = &Arc<ValidPoolTransaction<T>>> + '_ {
|
||||
self.by_hash.values()
|
||||
}
|
||||
|
||||
/// Returns if the transaction for the given hash is already included in this pool
|
||||
|
||||
Reference in New Issue
Block a user