From e902c10295ba430bf0522b92ffab68cd60bd1666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Mon, 27 Mar 2023 21:51:11 +0800 Subject: [PATCH] [bdk_chain_redesign] Fix `apply_additions` logic for `IndexedTxGraph`. --- crates/chain/src/indexed_tx_graph.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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`.