Skip to content

Commit 3af847e

Browse files
feat: implement set_lookahead_for_all on wallet
1 parent dfc1850 commit 3af847e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/bdk/src/wallet/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,6 +2312,21 @@ impl<D> Wallet<D> {
23122312
pub fn local_chain(&self) -> &LocalChain {
23132313
&self.chain
23142314
}
2315+
2316+
/// Set lookahead for all keychains.
2317+
///
2318+
/// Passing a lookahead of 0 will result in an error. This is because if we sync
2319+
/// the chain with a lookahead of 0, we would not find any update since we don't
2320+
/// have any scripts stored.
2321+
pub fn set_lookahead_for_all(&mut self, lookahead: u32) -> Result<(), Error> {
2322+
if lookahead == 0 {
2323+
return Err(Error::Generic(
2324+
"lookahead must be greater than 0".to_string(),
2325+
));
2326+
}
2327+
self.indexed_graph.index.set_lookahead_for_all(lookahead);
2328+
Ok(())
2329+
}
23152330
}
23162331

23172332
impl<D> AsRef<bdk_chain::tx_graph::TxGraph<ConfirmationTimeHeightAnchor>> for Wallet<D> {

0 commit comments

Comments
 (0)