From e3cfb84898cfa79d4903cf276fc69ffb0605b4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Tue, 30 Apr 2024 14:49:03 +0800 Subject: [PATCH] feat(chain): `TxGraph::insert_tx` reuses `Arc` When we insert a transaction that is already wrapped in `Arc`, we should reuse the `Arc`. --- crates/chain/src/tx_graph.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index cf514855..d097b8fa 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -516,12 +516,12 @@ impl TxGraph { /// Inserts the given transaction into [`TxGraph`]. /// /// The [`ChangeSet`] returned will be empty if `tx` already exists. - pub fn insert_tx(&mut self, tx: Transaction) -> ChangeSet { + pub fn insert_tx>>(&mut self, tx: T) -> ChangeSet { + let tx = tx.into(); let mut update = Self::default(); - update.txs.insert( - tx.txid(), - (TxNodeInternal::Whole(tx.into()), BTreeSet::new(), 0), - ); + update + .txs + .insert(tx.txid(), (TxNodeInternal::Whole(tx), BTreeSet::new(), 0)); self.apply_update(update) }