Skip to content

Commit

Permalink
feat: add AccountTransactionIndex insert (#316)
Browse files Browse the repository at this point in the history
Until we support fee escalation, this should always return None.

Subsequent PRs will use this DS, and panic if `Some` is returned.

commit-id:b0eee880

Co-authored-by: Gilad Chase <[email protected]>
  • Loading branch information
giladchase and Gilad Chase authored Jun 30, 2024
1 parent f077bb8 commit bd27a39
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/mempool/src/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ impl TransactionPool {
pub struct AccountTransactionIndex(
pub HashMap<ContractAddress, BTreeMap<Nonce, TransactionReference>>,
);

impl AccountTransactionIndex {
/// If the transaction already exists in the mapping, the old value is returned.
pub fn insert(&mut self, tx: TransactionReference) -> Option<TransactionReference> {
self.0.entry(tx.sender_address).or_default().insert(tx.nonce, tx)
}
}

0 comments on commit bd27a39

Please sign in to comment.