Skip to content

Commit aea1522

Browse files
vladimirfomeneevanlinjin
authored andcommitted
refactor: Implement Default for WalletUpdate
1 parent e78fa2a commit aea1522

File tree

3 files changed

+7
-8
lines changed
  • crates/bdk/src/wallet
  • example-crates

3 files changed

+7
-8
lines changed

crates/bdk/src/wallet/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ pub struct Wallet<D = ()> {
9494
secp: SecpCtx,
9595
}
9696

97-
/// A structure to update [`KeychainTxOutIndex`], [`TxGraph`] and [`LocalChain`] atomically.
97+
/// A structure to update [`Wallet`].
9898
///
99-
/// [`LocalChain`]: local_chain::LocalChain
99+
/// It updates [`bdk_chain::keychain::KeychainTxOutIndex`], [`bdk_chain::TxGraph`] and [`local_chain::LocalChain`] atomically.
100100
#[derive(Debug, Clone)]
101101
pub struct WalletUpdate<K, A> {
102102
/// Contains the last active derivation indices per keychain (`K`), which is used to update the
@@ -112,13 +112,12 @@ pub struct WalletUpdate<K, A> {
112112
pub chain: Option<local_chain::Update>,
113113
}
114114

115-
impl<K, A> WalletUpdate<K, A> {
116-
/// Construct a [`WalletUpdate`] with a given [`local_chain::Update`].
117-
pub fn new(chain_update: local_chain::Update) -> Self {
115+
impl<K, A> Default for WalletUpdate<K, A> {
116+
fn default() -> Self {
118117
Self {
119118
last_active_indices: BTreeMap::new(),
120119
graph: TxGraph::default(),
121-
chain: Some(chain_update),
120+
chain: None,
122121
}
123122
}
124123
}

example-crates/wallet_esplora_async/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6161
let update = WalletUpdate {
6262
last_active_indices,
6363
graph: update_graph,
64-
..WalletUpdate::new(chain_update)
64+
chain: Some(chain_update),
6565
};
6666
wallet.apply_update(update)?;
6767
wallet.commit()?;

example-crates/wallet_esplora_blocking/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6060
let update = WalletUpdate {
6161
last_active_indices,
6262
graph: update_graph,
63-
..WalletUpdate::new(chain_update)
63+
chain: Some(chain_update),
6464
};
6565

6666
wallet.apply_update(update)?;

0 commit comments

Comments
 (0)