Skip to content

Commit

Permalink
refactor(mempool): rearrange insert_tx before refactoring code to sha…
Browse files Browse the repository at this point in the history
…re functionality
  • Loading branch information
ayeletstarkware committed Aug 15, 2024
1 parent b6af979 commit 724c44d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/mempool/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ impl Mempool {
let MempoolInput { tx, account: Account { sender_address, state: AccountState { nonce } } } =
input;

self.tx_pool.remove_up_to_nonce(sender_address, nonce);
self.tx_pool.insert(tx)?;

// Align the queue with the account's nonce.
if self.tx_queue.get_nonce(sender_address).is_some_and(|queued_nonce| queued_nonce != nonce)
{
self.tx_queue.remove(sender_address);
}

self.tx_pool.insert(tx)?;

// Maybe close nonce gap.
if self.tx_queue.get_nonce(sender_address).is_none() {
if let Some(tx_reference) = self.tx_pool.get_by_address_and_nonce(sender_address, nonce)
Expand All @@ -150,6 +150,8 @@ impl Mempool {
}
}

self.tx_pool.remove_up_to_nonce(sender_address, nonce);

Ok(())
}

Expand Down

0 comments on commit 724c44d

Please sign in to comment.