diff --git a/crates/chain/src/indexed_tx_graph.rs b/crates/chain/src/indexed_tx_graph.rs index ed2a1f0ce..b2da7bf75 100644 --- a/crates/chain/src/indexed_tx_graph.rs +++ b/crates/chain/src/indexed_tx_graph.rs @@ -2,7 +2,7 @@ //! [`IndexedTxGraph`] documentation for more. use core::fmt::Debug; -use alloc::vec::Vec; +use alloc::{sync::Arc, vec::Vec}; use bitcoin::{Block, OutPoint, Transaction, TxOut, Txid}; use crate::{ @@ -133,13 +133,10 @@ where } /// Insert and index a transaction into the graph. - pub fn insert_tx(&mut self, tx: Transaction) -> ChangeSet { - let graph = self.graph.insert_tx(tx); - let indexer = self.index_tx_graph_changeset(&graph); - ChangeSet { - tx_graph: graph, - indexer, - } + pub fn insert_tx>>(&mut self, tx: T) -> ChangeSet { + let tx_graph = self.graph.insert_tx(tx); + let indexer = self.index_tx_graph_changeset(&tx_graph); + ChangeSet { tx_graph, indexer } } /// Insert an `anchor` for a given transaction. @@ -239,9 +236,9 @@ where /// To filter out irrelevant transactions, use [`batch_insert_relevant_unconfirmed`] instead. /// /// [`batch_insert_relevant_unconfirmed`]: IndexedTxGraph::batch_insert_relevant_unconfirmed - pub fn batch_insert_unconfirmed( + pub fn batch_insert_unconfirmed>>( &mut self, - txs: impl IntoIterator, + txs: impl IntoIterator, ) -> ChangeSet { let graph = self.graph.batch_insert_unconfirmed(txs); let indexer = self.index_tx_graph_changeset(&graph); diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index 127b47cf2..9a32ccdfc 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -606,12 +606,13 @@ impl TxGraph { /// Items of `txs` are tuples containing the transaction and a *last seen* timestamp. The /// *last seen* communicates when the transaction is last seen in mempool which is used for /// conflict-resolution (refer to [`TxGraph::insert_seen_at`] for details). - pub fn batch_insert_unconfirmed( + pub fn batch_insert_unconfirmed>>( &mut self, - txs: impl IntoIterator, + txs: impl IntoIterator, ) -> ChangeSet { let mut changeset = ChangeSet::::default(); for (tx, seen_at) in txs { + let tx: Arc = tx.into(); changeset.merge(self.insert_seen_at(tx.compute_txid(), seen_at)); changeset.merge(self.insert_tx(tx)); }