mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 00:58:11 -05:00
feat(tx-pool): add get_transactions_by_sender_and_nonce for TransactionPool trait (#5912)
This commit is contained in:
@@ -184,6 +184,7 @@ once_cell = "1.17"
|
||||
syn = "2.0"
|
||||
ahash = "0.8.6"
|
||||
|
||||
|
||||
# proc-macros
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
@@ -231,4 +232,4 @@ serial_test = "2"
|
||||
|
||||
[workspace.metadata.cargo-udeps.ignore]
|
||||
# ignored because this is mutually exclusive with the optimism payload builder via feature flags
|
||||
normal = ["reth-ethereum-payload-builder"]
|
||||
normal = ["reth-ethereum-payload-builder"]
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
#![deny(unused_must_use, rust_2018_idioms)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
use crate::pool::PoolInner;
|
||||
use crate::{identifier::TransactionId, pool::PoolInner};
|
||||
use aquamarine as _;
|
||||
use reth_primitives::{Address, BlobTransactionSidecar, PooledTransactionsElement, TxHash, U256};
|
||||
use reth_provider::StateProviderFactory;
|
||||
@@ -473,6 +473,20 @@ where
|
||||
self.pool.get_transactions_by_sender(sender)
|
||||
}
|
||||
|
||||
fn get_transactions_by_sender_and_nonce(
|
||||
&self,
|
||||
sender: Address,
|
||||
nonce: u64,
|
||||
) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
let transaction_id = TransactionId::new(self.pool.get_sender_id(sender), nonce);
|
||||
|
||||
self.inner()
|
||||
.get_pool_data()
|
||||
.all()
|
||||
.get(&transaction_id)
|
||||
.map(|tx| Arc::clone(&tx.transaction))
|
||||
}
|
||||
|
||||
fn get_transactions_by_origin(
|
||||
&self,
|
||||
origin: TransactionOrigin,
|
||||
|
||||
@@ -192,6 +192,14 @@ impl TransactionPool for NoopTransactionPool {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn get_transactions_by_sender_and_nonce(
|
||||
&self,
|
||||
_sender: Address,
|
||||
_nonce: u64,
|
||||
) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn unique_senders(&self) -> HashSet<Address> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ use crate::{
|
||||
CanonicalStateUpdate, ChangedAccount, PoolConfig, TransactionOrdering, TransactionValidator,
|
||||
};
|
||||
use best::BestTransactions;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use parking_lot::{Mutex, RwLock, RwLockReadGuard};
|
||||
use reth_primitives::{
|
||||
Address, BlobTransaction, BlobTransactionSidecar, IntoRecoveredTransaction,
|
||||
PooledTransactionsElement, TransactionSigned, TxHash, B256,
|
||||
@@ -279,6 +279,11 @@ where
|
||||
self.event_listener.write().subscribe_all()
|
||||
}
|
||||
|
||||
/// Returns a read lock to the pool's data.
|
||||
pub(crate) fn get_pool_data(&self) -> RwLockReadGuard<'_, TxPool<T>> {
|
||||
self.pool.read()
|
||||
}
|
||||
|
||||
/// Returns hashes of _all_ transactions in the pool.
|
||||
pub(crate) fn pooled_transactions_hashes(&self) -> Vec<TxHash> {
|
||||
let pool = self.pool.read();
|
||||
|
||||
@@ -929,7 +929,6 @@ impl<T: PoolTransaction> AllTransactions<T> {
|
||||
}
|
||||
|
||||
/// Returns the internal transaction with additional metadata
|
||||
#[cfg(test)]
|
||||
pub(crate) fn get(&self, id: &TransactionId) -> Option<&PoolInternalTransaction<T>> {
|
||||
self.txs.get(id)
|
||||
}
|
||||
|
||||
@@ -306,6 +306,13 @@ pub trait TransactionPool: Send + Sync + Clone {
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns a transaction sent by a given user with a given nonce
|
||||
fn get_transactions_by_sender_and_nonce(
|
||||
&self,
|
||||
sender: Address,
|
||||
nonce: u64,
|
||||
) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns all transactions that where submitted with the given [TransactionOrigin]
|
||||
fn get_transactions_by_origin(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user