feat(chain): TxGraph::insert_tx
reuses Arc
When we insert a transaction that is already wrapped in `Arc`, we should reuse the `Arc`.
This commit is contained in:
parent
2ffb65618a
commit
e3cfb84898
@ -516,12 +516,12 @@ impl<A: Clone + Ord> TxGraph<A> {
|
|||||||
/// Inserts the given transaction into [`TxGraph`].
|
/// Inserts the given transaction into [`TxGraph`].
|
||||||
///
|
///
|
||||||
/// The [`ChangeSet`] returned will be empty if `tx` already exists.
|
/// 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();
|
let mut update = Self::default();
|
||||||
update.txs.insert(
|
update
|
||||||
tx.txid(),
|
.txs
|
||||||
(TxNodeInternal::Whole(tx.into()), BTreeSet::new(), 0),
|
.insert(tx.txid(), (TxNodeInternal::Whole(tx), BTreeSet::new(), 0));
|
||||||
);
|
|
||||||
self.apply_update(update)
|
self.apply_update(update)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user