diff --git a/crates/mempool/src/transaction_queue.rs b/crates/mempool/src/transaction_queue.rs index 9dc070f2a..cf59f7fa9 100644 --- a/crates/mempool/src/transaction_queue.rs +++ b/crates/mempool/src/transaction_queue.rs @@ -3,6 +3,7 @@ use std::collections::{BTreeSet, HashMap}; use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::transaction::TransactionHash; +use starknet_mempool_types::mempool_types::ThinTransaction; use crate::mempool::TransactionReference; // Assumption: for the MVP only one transaction from the same contract class can be in the mempool @@ -50,6 +51,19 @@ impl TransactionQueue { } } +impl FromIterator for TransactionQueue { + fn from_iter(txs: I) -> Self + where + I: IntoIterator, + { + let mut queue = Self::default(); + for tx in txs { + queue.insert(TransactionReference::new(&tx)); + } + queue + } +} + #[derive(Clone, Debug, derive_more::Deref, derive_more::From)] struct QueuedTransaction(pub TransactionReference);