Skip to content

Commit

Permalink
feat(chain): TxGraph::insert_tx reuses Arc
Browse files Browse the repository at this point in the history
When we insert a transaction that is already wrapped in `Arc`, we should
reuse the `Arc`.
  • Loading branch information
evanlinjin committed Apr 30, 2024
1 parent 2540258 commit 4aa60ce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/chain/src/tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,12 @@ impl<A: Clone + Ord> TxGraph<A> {
/// 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<A> {
pub fn insert_tx<T: Into<Arc<Transaction>>>(&mut self, tx: T) -> ChangeSet<A> {
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)
}

Expand Down

0 comments on commit 4aa60ce

Please sign in to comment.