Changed inflate_update logic to not depend on Cow

As mentioned by @LLFourn:

1. We have a "sparse chain" from which there is a subset of txids M that are missing from graph.
2. There is also another subset C that are in the graph but their positions have changed.
3. We used the Cow to avoid copying/duplicating in memory transactions in subset C and M

Instead in inflate_update we could remove transactions in subset M and just clone data in subset C (which is usually tiny).
This commit is contained in:
志宇
2023-03-08 01:53:09 +13:00
parent 69cf6d7924
commit de9457fce6
2 changed files with 36 additions and 9 deletions

View File

@@ -21,7 +21,6 @@
//! [`bdk_electrum_example`]: https://github.com/LLFourn/bdk_core_staging/tree/master/bdk_electrum_example
use std::{
borrow::Cow,
collections::{BTreeMap, HashMap},
fmt::Debug,
};
@@ -249,7 +248,7 @@ impl<K: Ord + Clone + Debug, P: ChainPosition> ElectrumUpdate<K, P> {
self,
new_txs: Vec<T>,
chain_graph: &CG,
) -> Result<KeychainScan<K, P, Cow<T>>, chain_graph::NewError<P>>
) -> Result<KeychainScan<K, P, T>, chain_graph::NewError<P>>
where
T: AsTransaction + Clone + Ord,
CG: AsRef<ChainGraph<P, T>>,