diff --git a/crates/mempool/src/transaction_pool.rs b/crates/mempool/src/transaction_pool.rs index 6229a926e..a020b182c 100644 --- a/crates/mempool/src/transaction_pool.rs +++ b/crates/mempool/src/transaction_pool.rs @@ -80,3 +80,10 @@ impl TransactionPool { pub struct AccountTransactionIndex( pub HashMap>, ); + +impl AccountTransactionIndex { + /// If the transaction already exists in the mapping, the old value is returned. + pub fn insert(&mut self, tx: TransactionReference) -> Option { + self.0.entry(tx.sender_address).or_default().insert(tx.nonce, tx) + } +}