diff --git a/crates/chain/src/indexed_tx_graph.rs b/crates/chain/src/indexed_tx_graph.rs index 20d9958e..c4ee3209 100644 --- a/crates/chain/src/indexed_tx_graph.rs +++ b/crates/chain/src/indexed_tx_graph.rs @@ -117,14 +117,13 @@ where /// Insert relevant transactions from the given `txs` iterator. /// /// Relevancy is determined by the [`Indexer::is_tx_relevant`] implementation of `I`. Irrelevant - /// transactions in `txs` will be ignored. Also, `txs` does not need to be in topological order. + /// transactions in `txs` will be ignored. `txs` do not need to be in topological order. /// /// `anchors` can be provided to anchor the transactions to blocks. `seen_at` is a unix /// timestamp of when the transactions are last seen. pub fn insert_relevant_txs<'t>( &mut self, - txs: impl IntoIterator, - anchors: impl IntoIterator + Clone, + txs: impl IntoIterator)>, seen_at: Option, ) -> IndexedAdditions { // The algorithm below allows for non-topologically ordered transactions by using two loops. @@ -135,15 +134,15 @@ where // returns true or not. (in a second loop). let mut additions = IndexedAdditions::::default(); let mut transactions = Vec::new(); - for tx in txs.into_iter() { + for (tx, anchors) in txs.into_iter() { additions.index_additions.append(self.index.index_tx(tx)); - transactions.push(tx); + transactions.push((tx, anchors)); } additions.append( transactions .into_iter() - .filter_map(|tx| match self.index.is_tx_relevant(tx) { - true => Some(self.insert_tx(tx, anchors.clone(), seen_at)), + .filter_map(|(tx, anchors)| match self.index.is_tx_relevant(tx) { + true => Some(self.insert_tx(tx, anchors, seen_at)), false => None, }) .fold(Default::default(), |mut acc, other| { diff --git a/crates/chain/tests/test_indexed_tx_graph.rs b/crates/chain/tests/test_indexed_tx_graph.rs index 26a30cb8..4ca340d1 100644 --- a/crates/chain/tests/test_indexed_tx_graph.rs +++ b/crates/chain/tests/test_indexed_tx_graph.rs @@ -61,7 +61,7 @@ fn insert_relevant_txs() { let txs = [tx_c, tx_b, tx_a]; assert_eq!( - graph.insert_relevant_txs(&txs, None, None), + graph.insert_relevant_txs(txs.iter().map(|tx| (tx, None)), None), IndexedAdditions { graph_additions: Additions { tx: txs.into(),