Skip to content

Commit

Permalink
feat(mempool): remove addresses of reverted transactions from queue i…
Browse files Browse the repository at this point in the history
…n commit block method
  • Loading branch information
MohammadNassar1 committed Jul 18, 2024
1 parent 3dac360 commit 583bd99
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/mempool/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Mempool {
&mut self,
state_changes: HashMap<ContractAddress, AccountState>,
) -> MempoolResult<()> {
for (address, AccountState { nonce }) in state_changes {
for (&address, AccountState { nonce }) in state_changes.iter() {
let next_nonce = Nonce(nonce.0 + Felt::ONE);
// Dequeue transactions from the queue in the following cases:
// 1. Remove a transaction from queue with nonce lower and eq than those committed to
Expand All @@ -106,7 +106,17 @@ impl Mempool {
// TODO: remove the transactions from the tx_pool.
}
// TODO: update the tx_queue with the new state changes.
todo!()

// Iterate over the mempool state and remove any addresses from the transaction queue
// that do not appear in state_changes, as they were not included in the block.
for address in self.mempool_state.keys() {
if state_changes.get(address).is_none() {
self.tx_queue.remove(*address);
}
}
self.mempool_state.clear();

Ok(())
}

fn insert_tx(&mut self, input: MempoolInput) -> MempoolResult<()> {
Expand Down

0 comments on commit 583bd99

Please sign in to comment.