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 Jun 2, 2024
1 parent ac99c1c commit 0ce25b9
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::HashMap;
use std::collections::{BTreeSet, HashMap};

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

Expand All @@ -38,6 +39,7 @@ impl Mempool {
txs_queue: TransactionPriorityQueue::default(),
tx_store: TransactionStore::default(),
state: HashMap::default(),
staging: BTreeSet::default(),
gateway_network,
batcher_network,
};
Expand Down Expand Up @@ -82,6 +84,7 @@ impl Mempool {
for pq_tx in &pq_txs {
let tx = self.tx_store.remove(&pq_tx.tx_hash).unwrap();
self.state.remove(&tx.sender_address);
self.staging.insert(pq_tx.tx_hash);
txs.push(tx);
}

Expand Down

0 comments on commit 0ce25b9

Please sign in to comment.