Skip to content

Commit e902c10

Browse files
committed
[bdk_chain_redesign] Fix apply_additions logic for IndexedTxGraph.
1 parent 313965d commit e902c10

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

crates/chain/src/indexed_tx_graph.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct TxOutInChain<'a, I, A> {
2222
pub txout: FullTxOut<ObservedIn<&'a A>>,
2323
}
2424

25+
#[must_use]
2526
pub struct IndexedAdditions<A, D> {
2627
pub graph_additions: Additions<A>,
2728
pub index_delta: D,
@@ -83,8 +84,17 @@ impl<A: BlockAnchor, I: TxIndex> IndexedTxGraph<A, I> {
8384
graph_additions,
8485
index_delta,
8586
} = additions;
86-
self.graph.apply_additions(graph_additions);
87+
8788
self.index.apply_additions(index_delta);
89+
90+
for tx in &graph_additions.tx {
91+
self.index.index_tx(tx);
92+
}
93+
for (&outpoint, txout) in &graph_additions.txout {
94+
self.index.index_txout(outpoint, txout);
95+
}
96+
97+
self.graph.apply_additions(graph_additions);
8898
}
8999

90100
/// Insert a `txout` that exists in `outpoint` with the given `observation`.

0 commit comments

Comments
 (0)