Skip to content

Commit

Permalink
feat(mempool): implement remove method for transaction queue (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 authored Jul 11, 2024
1 parent 93fbc48 commit 3a06dd9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/mempool/src/transaction_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ impl TransactionQueue {
pub fn _get_nonce(&self, address: ContractAddress) -> Option<Nonce> {
self.address_to_tx.get(&address).map(|tx| tx.nonce)
}

/// Removes the transaction of the given account address from the queue.
/// This is well-defined, since there is at most one transaction per address in the queue.
pub fn _remove(&mut self, address: ContractAddress) -> bool {
if let Some(tx) = self.address_to_tx.remove(&address) {
return self.queue.remove(&tx.into());
}
false
}
}

/// Encapsulates a transaction reference to assess its order (i.e., priority).
Expand Down

0 comments on commit 3a06dd9

Please sign in to comment.