Skip to content

Commit 6a97e5e

Browse files
committed
feat(chain): TxGraph::insert_tx reuses Arc
When we insert a transaction that is already wrapped in `Arc`, we should reuse the `Arc`.
1 parent 7cb97eb commit 6a97e5e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/chain/src/tx_graph.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,12 @@ impl<A: Clone + Ord> TxGraph<A> {
516516
/// Inserts the given transaction into [`TxGraph`].
517517
///
518518
/// The [`ChangeSet`] returned will be empty if `tx` already exists.
519-
pub fn insert_tx(&mut self, tx: Transaction) -> ChangeSet<A> {
519+
pub fn insert_tx<T: Into<Arc<Transaction>>>(&mut self, tx: T) -> ChangeSet<A> {
520+
let tx = tx.into();
520521
let mut update = Self::default();
521-
update.txs.insert(
522-
tx.txid(),
523-
(TxNodeInternal::Whole(tx.into()), BTreeSet::new(), 0),
524-
);
522+
update
523+
.txs
524+
.insert(tx.txid(), (TxNodeInternal::Whole(tx), BTreeSet::new(), 0));
525525
self.apply_update(update)
526526
}
527527

0 commit comments

Comments
 (0)