[wallet_redesign] Move the majority of Update to bdk_chain

This is to make it easier for chain source crates to formulate updates.
This commit is contained in:
志宇
2023-05-11 18:46:41 +08:00
parent e69fccb15f
commit aba88130d9
2 changed files with 26 additions and 10 deletions

View File

@@ -18,6 +18,7 @@
use crate::{
chain_graph::{self, ChainGraph},
collections::BTreeMap,
local_chain::LocalChain,
sparse_chain::ChainPosition,
tx_graph::TxGraph,
Append, ForEachTxOut,
@@ -102,6 +103,28 @@ impl<K> AsRef<BTreeMap<K, u32>> for DerivationAdditions<K> {
}
}
/// A structure to update [`KeychainTxOutIndex`], [`TxGraph`] and [`LocalChain`]
/// atomically.
#[derive(Debug, Clone, PartialEq)]
pub struct LocalUpdate<K, A> {
/// Last active derivation index per keychain (`K`).
pub keychain: BTreeMap<K, u32>,
/// Update for the [`TxGraph`].
pub graph: TxGraph<A>,
/// Update for the [`LocalChain`].
pub chain: LocalChain,
}
impl<K, A> Default for LocalUpdate<K, A> {
fn default() -> Self {
Self {
keychain: Default::default(),
graph: Default::default(),
chain: Default::default(),
}
}
}
#[derive(Clone, Debug, PartialEq)]
/// An update that includes the last active indexes of each keychain.
pub struct KeychainScan<K, P> {