Skip to content

Commit a28748c

Browse files
vladimirfomeneevanlinjin
authored andcommitted
refactor: Implement Default for WalletUpdate
1 parent f42f8b8 commit a28748c

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
@@ -95,9 +95,9 @@ pub struct Wallet<D = ()> {
9595
secp: SecpCtx,
9696
}
9797

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

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

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)