mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add pending|queued txs pool helpers (#12128)
This commit is contained in:
@ -503,6 +503,20 @@ where
|
||||
self.pool.get_transactions_by_sender(sender)
|
||||
}
|
||||
|
||||
fn get_pending_transactions_by_sender(
|
||||
&self,
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
self.pool.get_pending_transactions_by_sender(sender)
|
||||
}
|
||||
|
||||
fn get_queued_transactions_by_sender(
|
||||
&self,
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
self.pool.get_queued_transactions_by_sender(sender)
|
||||
}
|
||||
|
||||
fn get_highest_transaction_by_sender(
|
||||
&self,
|
||||
sender: Address,
|
||||
|
||||
@ -220,6 +220,20 @@ impl TransactionPool for NoopTransactionPool {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn get_pending_transactions_by_sender(
|
||||
&self,
|
||||
_sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn get_queued_transactions_by_sender(
|
||||
&self,
|
||||
_sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn get_highest_transaction_by_sender(
|
||||
&self,
|
||||
_sender: Address,
|
||||
|
||||
@ -776,6 +776,24 @@ where
|
||||
self.get_pool_data().get_transactions_by_sender(sender_id)
|
||||
}
|
||||
|
||||
/// Returns all queued transactions of the address by sender
|
||||
pub(crate) fn get_queued_transactions_by_sender(
|
||||
&self,
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
let sender_id = self.get_sender_id(sender);
|
||||
self.get_pool_data().pending_txs_by_sender(sender_id)
|
||||
}
|
||||
|
||||
/// Returns all pending transactions of the address by sender
|
||||
pub(crate) fn get_pending_transactions_by_sender(
|
||||
&self,
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
let sender_id = self.get_sender_id(sender);
|
||||
self.get_pool_data().queued_txs_by_sender(sender_id)
|
||||
}
|
||||
|
||||
/// Returns the highest transaction of the address
|
||||
pub(crate) fn get_highest_transaction_by_sender(
|
||||
&self,
|
||||
|
||||
@ -364,11 +364,26 @@ impl<T: TransactionOrdering> TxPool<T> {
|
||||
self.pending_pool.all()
|
||||
}
|
||||
|
||||
/// Returns all pending transactions for the specified sender
|
||||
pub(crate) fn pending_txs_by_sender(
|
||||
&self,
|
||||
sender: SenderId,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
self.pending_transactions_iter().filter(|tx| tx.sender_id() == sender).collect()
|
||||
}
|
||||
|
||||
/// Returns all transactions from parked pools
|
||||
pub(crate) fn queued_transactions(&self) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
self.basefee_pool.all().chain(self.queued_pool.all()).collect()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all transactions from parked pools
|
||||
pub(crate) fn queued_transactions_iter(
|
||||
&self,
|
||||
) -> impl Iterator<Item = Arc<ValidPoolTransaction<T::Transaction>>> + '_ {
|
||||
self.basefee_pool.all().chain(self.queued_pool.all())
|
||||
}
|
||||
|
||||
/// Returns queued and pending transactions for the specified sender
|
||||
pub fn queued_and_pending_txs_by_sender(
|
||||
&self,
|
||||
@ -377,6 +392,14 @@ impl<T: TransactionOrdering> TxPool<T> {
|
||||
(self.queued_pool.get_txs_by_sender(sender), self.pending_pool.get_txs_by_sender(sender))
|
||||
}
|
||||
|
||||
/// Returns all queued transactions for the specified sender
|
||||
pub(crate) fn queued_txs_by_sender(
|
||||
&self,
|
||||
sender: SenderId,
|
||||
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
|
||||
self.queued_transactions_iter().filter(|tx| tx.sender_id() == sender).collect()
|
||||
}
|
||||
|
||||
/// Returns `true` if the transaction with the given hash is already included in this pool.
|
||||
pub(crate) fn contains(&self, tx_hash: &TxHash) -> bool {
|
||||
self.all_transactions.contains(tx_hash)
|
||||
|
||||
@ -352,6 +352,18 @@ pub trait TransactionPool: Send + Sync + Clone {
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns all pending transactions sent by a given user
|
||||
fn get_pending_transactions_by_sender(
|
||||
&self,
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns all queued transactions sent by a given user
|
||||
fn get_queued_transactions_by_sender(
|
||||
&self,
|
||||
sender: Address,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns the highest transaction sent by a given user
|
||||
fn get_highest_transaction_by_sender(
|
||||
&self,
|
||||
@ -1332,7 +1344,7 @@ impl TryFrom<TransactionSignedEcRecovered> for EthPooledTransaction {
|
||||
}
|
||||
EIP4844_TX_TYPE_ID => {
|
||||
// doesn't have a blob sidecar
|
||||
return Err(TryFromRecoveredTransactionError::BlobSidecarMissing)
|
||||
return Err(TryFromRecoveredTransactionError::BlobSidecarMissing);
|
||||
}
|
||||
unsupported => {
|
||||
// unsupported transaction type
|
||||
|
||||
Reference in New Issue
Block a user