feat: add get_highest_tx_by_sender to pools (#11514)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
tedison
2024-10-07 07:42:56 -04:00
committed by GitHub
parent f5c9701e72
commit f8228482ac
5 changed files with 43 additions and 14 deletions

View File

@ -489,6 +489,13 @@ where
self.pool.get_transactions_by_sender(sender)
}
fn get_highest_transaction_by_sender(
&self,
sender: Address,
) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>> {
self.pool.get_highest_transaction_by_sender(sender)
}
fn get_transaction_by_sender_and_nonce(
&self,
sender: Address,

View File

@ -206,6 +206,13 @@ impl TransactionPool for NoopTransactionPool {
vec![]
}
fn get_highest_transaction_by_sender(
&self,
_sender: Address,
) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>> {
None
}
fn get_transaction_by_sender_and_nonce(
&self,
_sender: Address,

View File

@ -744,6 +744,15 @@ where
self.get_pool_data().get_transactions_by_sender(sender_id)
}
/// Returns the highest transaction of the address
pub(crate) fn get_highest_transaction_by_sender(
&self,
sender: Address,
) -> Option<Arc<ValidPoolTransaction<T::Transaction>>> {
let sender_id = self.get_sender_id(sender);
self.get_pool_data().get_highest_transaction_by_sender(sender_id)
}
/// Returns all transactions that where submitted with the given [`TransactionOrigin`]
pub(crate) fn get_transactions_by_origin(
&self,

View File

@ -334,6 +334,12 @@ pub trait TransactionPool: Send + Sync + Clone {
sender: Address,
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
/// Returns the highest transaction sent by a given user
fn get_highest_transaction_by_sender(
&self,
sender: Address,
) -> Option<Arc<ValidPoolTransaction<Self::Transaction>>>;
/// Returns a transaction sent by a given user and a nonce
fn get_transaction_by_sender_and_nonce(
&self,