mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
chore(txpool): add pooled transaction function to get full tx object (#1483)
This commit is contained in:
@@ -225,7 +225,11 @@ where
|
||||
self.pool.add_transaction_listener()
|
||||
}
|
||||
|
||||
fn pooled_transactions(&self) -> Vec<TxHash> {
|
||||
fn pooled_transaction_hashes(&self) -> Vec<TxHash> {
|
||||
self.pool.pooled_transactions_hashes()
|
||||
}
|
||||
|
||||
fn pooled_transactions(&self) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
self.pool.pooled_transactions()
|
||||
}
|
||||
|
||||
|
||||
@@ -172,11 +172,17 @@ where
|
||||
}
|
||||
|
||||
/// Returns hashes of _all_ transactions in the pool.
|
||||
pub(crate) fn pooled_transactions(&self) -> Vec<TxHash> {
|
||||
pub(crate) fn pooled_transactions_hashes(&self) -> Vec<TxHash> {
|
||||
let pool = self.pool.read();
|
||||
pool.all().hashes_iter().collect()
|
||||
}
|
||||
|
||||
/// Returns _all_ transactions in the pool.
|
||||
pub(crate) fn pooled_transactions(&self) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
let pool = self.pool.read();
|
||||
pool.all().transactions_iter().collect()
|
||||
}
|
||||
|
||||
/// Updates the entire pool after a new block was executed.
|
||||
pub(crate) fn on_new_block(&self, block: OnNewBlockEvent) {
|
||||
let outcome = self.pool.write().on_new_block(block);
|
||||
|
||||
@@ -512,6 +512,13 @@ impl<T: PoolTransaction> AllTransactions<T> {
|
||||
self.by_hash.keys().copied()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all _unique_ hashes in the pool
|
||||
pub(crate) fn transactions_iter(
|
||||
&self,
|
||||
) -> impl Iterator<Item = Arc<ValidPoolTransaction<T>>> + '_ {
|
||||
self.by_hash.values().cloned()
|
||||
}
|
||||
|
||||
/// Returns if the transaction for the given hash is already included in this pool
|
||||
pub(crate) fn contains(&self, tx_hash: &TxHash) -> bool {
|
||||
self.by_hash.contains_key(tx_hash)
|
||||
|
||||
@@ -70,12 +70,19 @@ pub trait TransactionPool: Send + Sync + Clone {
|
||||
/// Returns a new stream that yields new valid transactions added to the pool.
|
||||
fn transactions_listener(&self) -> Receiver<NewTransactionEvent<Self::Transaction>>;
|
||||
|
||||
/// Returns hashes of all transactions in the pool.
|
||||
/// Returns the _hashes_ of all transactions in the pool.
|
||||
///
|
||||
/// Note: This returns a `Vec` but should guarantee that all hashes are unique.
|
||||
///
|
||||
/// Consumer: P2P
|
||||
fn pooled_transactions(&self) -> Vec<TxHash>;
|
||||
fn pooled_transaction_hashes(&self) -> Vec<TxHash>;
|
||||
|
||||
/// Returns the _full_ transaction objects all transactions in the pool.
|
||||
///
|
||||
/// Note: This returns a `Vec` but should guarantee that all transactions are unique.
|
||||
///
|
||||
/// Consumer: P2P
|
||||
fn pooled_transactions(&self) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns an iterator that yields transactions that are ready for block production.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user