Skip to content

Commit

Permalink
[bdk_chain_redesign] Fix apply_additions logic for IndexedTxGraph.
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlinjin committed Mar 27, 2023
1 parent 313965d commit e902c10
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/chain/src/indexed_tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct TxOutInChain<'a, I, A> {
pub txout: FullTxOut<ObservedIn<&'a A>>,
}

#[must_use]
pub struct IndexedAdditions<A, D> {
pub graph_additions: Additions<A>,
pub index_delta: D,
Expand Down Expand Up @@ -83,8 +84,17 @@ impl<A: BlockAnchor, I: TxIndex> IndexedTxGraph<A, I> {
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`.
Expand Down

0 comments on commit e902c10

Please sign in to comment.