Skip to content

Commit 304f69f

Browse files
randomloginfebyeji
authored andcommitted
Bump kyoto version (#20)
* Use kyoto's rescan_from(h) instead of rescan() Previously rescan would go from kyoto's build-time checkpoint, which might be a very old block. We can explicitely use rescan_from(height) to process only new blocks. * Bump kyoto version to 0.6.0
1 parent 7faa5ae commit 304f69f

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ lightning-dns-resolver = { git = "https://github.com/lightningdevkit/rust-lightn
5656
bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
5757
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
5858
bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls-ring"]}
59-
bip157 = { version = "0.5.0", default-features = false }
59+
bip157 = { version = "0.6.0", default-features = false }
6060
bdk_wallet = { version = "2.3.0", default-features = false, features = ["std", "keys-bip39"]}
6161

6262
bitreq = { version = "0.3", default-features = false, features = ["async-https", "json-using-serde"] }

src/chain/cbf.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use bdk_wallet::{KeychainKind, Update};
1717
use bip157::chain::{BlockHeaderChanges, ChainState};
1818
use bip157::error::FetchBlockError;
1919
use bip157::{
20-
BlockHash, Builder, Client, Event, HeaderCheckpoint, Info, Node as CbfNode, Requester,
20+
BlockHash, Builder, Client, Event, HashCheckpoint, Info, Node as CbfNode, Requester,
2121
SyncUpdate, TrustedPeer, Warning,
2222
};
2323
use bitcoin::constants::SUBSIDY_HALVING_INTERVAL;
@@ -242,7 +242,7 @@ impl CbfChainSource {
242242
}
243243
}
244244
if cursor.height() > 0 {
245-
let header_cp = HeaderCheckpoint::new(cursor.height(), cursor.hash());
245+
let header_cp = HashCheckpoint::new(cursor.height(), cursor.hash());
246246
builder = builder.chain_state(ChainState::Checkpoint(header_cp));
247247
log_debug!(
248248
logger,
@@ -548,7 +548,14 @@ impl CbfChainSource {
548548
let (tx, rx) = oneshot::channel();
549549
*self.sync_completion_tx.lock().expect("lock") = Some(tx);
550550

551-
if let Err(e) = requester.rescan().map_err(|e| {
551+
// Delegate the skip to kyoto so it doesn't re-stream filters we would discard
552+
// client-side via filter_skip_height. Without `_from`, kyoto replays from its
553+
// build-time checkpoint (potentially genesis on a fresh wallet) every tick.
554+
let rescan_res = match skip_before_height {
555+
Some(h) => requester.rescan_from(h),
556+
None => requester.rescan(),
557+
};
558+
if let Err(e) = rescan_res.map_err(|e| {
552559
log_error!(self.logger, "Failed to trigger CBF rescan: {:?}", e);
553560
Error::WalletOperationFailed
554561
}) {

0 commit comments

Comments
 (0)