From: 志宇 Date: Mon, 27 Mar 2023 13:51:11 +0000 (+0800) Subject: [bdk_chain_redesign] Fix `apply_additions` logic for `IndexedTxGraph`. X-Git-Tag: v1.0.0-alpha.1~19^2~39 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.CommandStringError.html?a=commitdiff_plain;h=e902c10295ba430bf0522b92ffab68cd60bd1666;p=bdk [bdk_chain_redesign] Fix `apply_additions` logic for `IndexedTxGraph`. --- diff --git a/crates/chain/src/indexed_tx_graph.rs b/crates/chain/src/indexed_tx_graph.rs index 91ecd571..4245e57d 100644 --- a/crates/chain/src/indexed_tx_graph.rs +++ b/crates/chain/src/indexed_tx_graph.rs @@ -22,6 +22,7 @@ pub struct TxOutInChain<'a, I, A> { pub txout: FullTxOut>, } +#[must_use] pub struct IndexedAdditions { pub graph_additions: Additions, pub index_delta: D, @@ -83,8 +84,17 @@ impl IndexedTxGraph { graph_additions, index_delta, } = additions; - self.graph.apply_additions(graph_additions); + self.index.apply_additions(index_delta); + + for tx in &graph_additions.tx { + self.index.index_tx(tx); + } + for (&outpoint, txout) in &graph_additions.txout { + self.index.index_txout(outpoint, txout); + } + + self.graph.apply_additions(graph_additions); } /// Insert a `txout` that exists in `outpoint` with the given `observation`.