Skip to content

Commit

Permalink
feat(mempool): insert eligible tx to tx queue in commit-block accordi…
Browse files Browse the repository at this point in the history
…ng to state changes
  • Loading branch information
MohammadNassar1 committed Jul 23, 2024
1 parent 9986c59 commit a26b234
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/mempool/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,19 @@ impl Mempool {
state_changes: HashMap<ContractAddress, AccountState>,
) -> MempoolResult<()> {
for (address, AccountState { nonce }) in state_changes {
// Dequeue transactions from the queue in the following cases:
// 1. Remove a transaction from queue with nonce lower than those committed to the
// block, applicable when the block is from the same leader.
// 2. Remove a transaction from queue with nonce greater than those committed to the
// block, applicable when the block is from a different leader.
// Align the queue with the committed nonces.
if self.tx_queue.get_nonce(address).is_some_and(|queued_nonce| queued_nonce != nonce) {
self.tx_queue.remove(address);
}
if self.tx_queue.get_nonce(address).is_none() {
if let Some(tx) = self.tx_pool.get_by_address_and_nonce(address, nonce) {
self.tx_queue.insert(*tx);
}
}

// TODO: remove the transactions from the tx_pool.
}
// TODO: update the tx_queue with the new state changes.
todo!()
Ok(())
}

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

0 comments on commit a26b234

Please sign in to comment.