refactor: move WalletChangeset to wallet module

Consequently, remove the `WalletChangeset` dependency from
`example_electrum` and `example_esplora` examples.
This commit is contained in:
Vladimir Fomene
2023-08-21 15:18:16 +03:00
committed by 志宇
parent 2392e50fd9
commit 68572bfd2e
5 changed files with 98 additions and 93 deletions

View File

@@ -7,7 +7,7 @@ use std::{
use bdk_chain::{
bitcoin::{Address, Network, OutPoint, ScriptBuf, Txid},
indexed_tx_graph::{self, IndexedTxGraph},
keychain::WalletChangeSet,
keychain,
local_chain::{self, LocalChain},
Append, ConfirmationHeightAnchor,
};
@@ -60,7 +60,10 @@ pub struct ScanOptions {
pub batch_size: usize,
}
type ChangeSet = WalletChangeSet<Keychain, ConfirmationHeightAnchor>;
type ChangeSet = (
local_chain::ChangeSet,
indexed_tx_graph::ChangeSet<ConfirmationHeightAnchor, keychain::ChangeSet<Keychain>>,
);
fn main() -> anyhow::Result<()> {
let (args, keymap, index, db, init_changeset) =
@@ -68,11 +71,11 @@ fn main() -> anyhow::Result<()> {
let graph = Mutex::new({
let mut graph = IndexedTxGraph::new(index);
graph.apply_changeset(init_changeset.indexed_tx_graph);
graph.apply_changeset(init_changeset.1);
graph
});
let chain = Mutex::new(LocalChain::from_changeset(init_changeset.chain));
let chain = Mutex::new(LocalChain::from_changeset(init_changeset.0));
let electrum_url = match args.network {
Network::Bitcoin => "ssl://electrum.blockstream.info:50002",
@@ -293,10 +296,7 @@ fn main() -> anyhow::Result<()> {
changeset
};
ChangeSet {
indexed_tx_graph,
chain,
}
(chain, indexed_tx_graph)
};
let mut db = db.lock().unwrap();