From 554b01fa64bfccada13da04579fd85d3aa498a25 Mon Sep 17 00:00:00 2001 From: Mohammad Nassar Date: Sun, 14 Jul 2024 14:19:50 +0300 Subject: [PATCH] feat(mempool): insert eligible tx to tx queue in commit-block according to state changes --- crates/mempool/src/mempool.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/mempool/src/mempool.rs b/crates/mempool/src/mempool.rs index e109800e4..7fcded282 100644 --- a/crates/mempool/src/mempool.rs +++ b/crates/mempool/src/mempool.rs @@ -82,9 +82,17 @@ impl Mempool { self.tx_queue.remove(address); } // TODO: remove the transactions from the tx_pool. + + // Insert an eligible transaction into the queue with a nonce matching the state + // changes. This is applicable when the block originates from a different + // leader. + 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: update the tx_queue with the new state changes. - todo!() + Ok(()) } fn insert_tx(&mut self, input: MempoolInput) -> MempoolResult<()> {