[bdk_chain_redesign] Add apply_additions to IndexedTxGraph

* Get mutable index from `IndexedChainGraph`.
* Also add `apply_additions` method to `TxIndex` trait.
This commit is contained in:
志宇
2023-03-27 15:36:37 +08:00
parent 6cbb18d409
commit d0a2aa83be
4 changed files with 26 additions and 0 deletions

View File

@@ -71,6 +71,21 @@ impl<A: BlockAnchor, I: TxIndex> IndexedTxGraph<A, I> {
&self.index
}
/// Get a mutable reference to the internal transaction index.
pub fn mut_index(&mut self) -> &mut I {
&mut self.index
}
/// Applies the [`IndexedAdditions`] to the [`IndexedTxGraph`].
pub fn apply_additions(&mut self, additions: IndexedAdditions<A, I::Additions>) {
let IndexedAdditions {
graph_additions,
index_delta,
} = additions;
self.graph.apply_additions(graph_additions);
self.index.apply_additions(index_delta);
}
/// Insert a `txout` that exists in `outpoint` with the given `observation`.
pub fn insert_txout(
&mut self,