Skip to content

Commit

Permalink
feat(mempool): add from_iter func to TransactionQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeletstarkware committed Jul 10, 2024
1 parent c025838 commit 282dcf3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/mempool/src/mempool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use starknet_types_core::felt::Felt;

use crate::mempool::{Mempool, MempoolInput, TransactionReference};
use crate::transaction_pool::TransactionPool;
use crate::transaction_queue::TransactionQueue;

impl FromIterator<ThinTransaction> for TransactionPool {
fn from_iter<T: IntoIterator<Item = ThinTransaction>>(txs: T) -> Self {
Expand All @@ -23,6 +24,16 @@ impl FromIterator<ThinTransaction> for TransactionPool {
}
}

impl FromIterator<TransactionReference> for TransactionQueue {
fn from_iter<T: IntoIterator<Item = TransactionReference>>(txs: T) -> Self {
let mut queue = Self::default();
for tx in txs {
queue.insert(tx);
}
queue
}
}

#[track_caller]
fn add_tx(mempool: &mut Mempool, input: &MempoolInput) {
assert_eq!(mempool.add_tx(input.clone()), Ok(()));
Expand Down

0 comments on commit 282dcf3

Please sign in to comment.