]> Untitled Git - bdk/commitdiff
refactor(chain): use `apply_update` instead of `determine_changeset` + `apply_changeset`
authorWei Chen <wzc110@gmail.com>
Thu, 24 Aug 2023 12:25:14 +0000 (20:25 +0800)
committerWei Chen <wzc110@gmail.com>
Fri, 25 Aug 2023 07:14:56 +0000 (15:14 +0800)
crates/chain/src/tx_graph.rs

index 5912921a920652dd8f465e1e3ef2bc9896430701..adb84ca2212ac497324e8ccfc362efc259cecf10 100644 (file)
@@ -385,9 +385,7 @@ impl<A: Clone + Ord> TxGraph<A> {
                 0,
             ),
         );
-        let changeset = self.determine_changeset(update);
-        self.apply_changeset(changeset.clone());
-        changeset
+        self.apply_update(update)
     }
 
     /// Inserts the given transaction into [`TxGraph`].
@@ -398,9 +396,7 @@ impl<A: Clone + Ord> TxGraph<A> {
         update
             .txs
             .insert(tx.txid(), (TxNodeInternal::Whole(tx), BTreeSet::new(), 0));
-        let changeset = self.determine_changeset(update);
-        self.apply_changeset(changeset.clone());
-        changeset
+        self.apply_update(update)
     }
 
     /// Inserts the given `anchor` into [`TxGraph`].
@@ -410,9 +406,7 @@ impl<A: Clone + Ord> TxGraph<A> {
     pub fn insert_anchor(&mut self, txid: Txid, anchor: A) -> ChangeSet<A> {
         let mut update = Self::default();
         update.anchors.insert((anchor, txid));
-        let changeset = self.determine_changeset(update);
-        self.apply_changeset(changeset.clone());
-        changeset
+        self.apply_update(update)
     }
 
     /// Inserts the given `seen_at` for `txid` into [`TxGraph`].
@@ -422,9 +416,7 @@ impl<A: Clone + Ord> TxGraph<A> {
         let mut update = Self::default();
         let (_, _, update_last_seen) = update.txs.entry(txid).or_default();
         *update_last_seen = seen_at;
-        let changeset = self.determine_changeset(update);
-        self.apply_changeset(changeset.clone());
-        changeset
+        self.apply_update(update)
     }
 
     /// Extends this graph with another so that `self` becomes the union of the two sets of