Skip to content

Commit

Permalink
refactor(mempool): remove redundunt pub from account transaction inde…
Browse files Browse the repository at this point in the history
…s struct of tx pool (#423)
  • Loading branch information
MohammadNassar1 authored Jul 10, 2024
1 parent 2c64fcd commit 025f4c3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/mempool/src/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ impl TransactionPool {
}

#[derive(Debug, Default)]
struct AccountTransactionIndex(pub HashMap<ContractAddress, BTreeMap<Nonce, TransactionReference>>);
struct AccountTransactionIndex(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> {
fn insert(&mut self, tx: TransactionReference) -> Option<TransactionReference> {
self.0.entry(tx.sender_address).or_default().insert(tx.nonce, tx)
}

pub fn remove(&mut self, tx: TransactionReference) -> Option<TransactionReference> {
fn remove(&mut self, tx: TransactionReference) -> Option<TransactionReference> {
let TransactionReference { sender_address, nonce, .. } = tx;
let account_txs = self.0.get_mut(&sender_address)?;

Expand All @@ -94,7 +94,7 @@ impl AccountTransactionIndex {
removed_tx
}

pub fn get(&self, address: ContractAddress, nonce: Nonce) -> Option<&TransactionReference> {
fn get(&self, address: ContractAddress, nonce: Nonce) -> Option<&TransactionReference> {
self.0.get(&address)?.get(&nonce)
}
}

0 comments on commit 025f4c3

Please sign in to comment.