Skip to content

Commit

Permalink
feat: add staging area
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadNassar1 committed May 30, 2024
1 parent 0a5e971 commit bb6509b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/mempool/src/mempool.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::{BTreeMap, HashMap};
use std::collections::{BTreeMap, BTreeSet, HashMap};

use anyhow::Result;
use mempool_infra::network_component::CommunicationInterface;
Expand All @@ -25,6 +25,7 @@ pub struct Mempool {
txs_queue: TransactionPriorityQueue,
tx_store: HashMap<ContractAddress, BTreeMap<Nonce, ThinTransaction>>,
tx_hash_2_tx: HashMap<TransactionHash, ThinTransaction>,
staging: BTreeSet<TransactionHash>,
state: HashMap<ContractAddress, AccountState>,
}

Expand All @@ -39,6 +40,7 @@ impl Mempool {
tx_store: HashMap::default(),
state: HashMap::default(),
tx_hash_2_tx: HashMap::default(),
staging: BTreeSet::default(),
gateway_network,
batcher_network,
};
Expand Down Expand Up @@ -87,6 +89,7 @@ impl Mempool {

let mut txs: Vec<ThinTransaction> = Vec::default();
for pq_tx in &pq_txs {
self.staging.insert(pq_tx.tx_hash);
let tx = self.tx_hash_2_tx.remove(&pq_tx.tx_hash).unwrap();
self.state.remove(&tx.sender_address);
self.tx_store.remove(&tx.sender_address);
Expand Down

0 comments on commit bb6509b

Please sign in to comment.