Merge bitcoindevkit/bdk#1092: Use apply_update instead of determine_changeset + apply_changeset around the code

c753584379185b0bd19d130ca39e44c8a6a65e65 refactor(chain): use `apply_update` instead of `determine_changeset` + `apply_changeset` (Wei Chen)

Pull request description:

  This PR implements #1081

ACKs for top commit:
  evanlinjin:
    ACK c753584379185b0bd19d130ca39e44c8a6a65e65

Tree-SHA512: cfb66a427dd76b8d11e07be24de9ba06958cda114b8eec260d492d30fba5a1cecbee2bb3e83b8636f9049eb8e920ad13aa76651a97a01290f53b0c7da8849b41
This commit is contained in:
志宇 2023-08-25 15:21:27 +08:00
commit 381c560c10
No known key found for this signature in database
GPG Key ID: F6345C9837C2BDE8

View 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