Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(mempool): remove redandunt pub from account transaction inde… #423

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading