From: Wei Chen Date: Thu, 24 Aug 2023 12:25:14 +0000 (+0800) Subject: refactor(chain): use `apply_update` instead of `determine_changeset` + `apply_changeset` X-Git-Tag: v1.0.0-alpha.2~21^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/enum.EncodeError.html?a=commitdiff_plain;h=c753584379185b0bd19d130ca39e44c8a6a65e65;p=bdk refactor(chain): use `apply_update` instead of `determine_changeset` + `apply_changeset` --- diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index 5912921a..adb84ca2 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -385,9 +385,7 @@ impl TxGraph { 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 TxGraph { 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 TxGraph { pub fn insert_anchor(&mut self, txid: Txid, anchor: A) -> ChangeSet { 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 TxGraph { 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