Skip to content

Commit 187b18d

Browse files
randomloginclaude
authored andcommitted
fix(cbf): advance lightning-wallet sync timestamp when no scripts registered
`sync_lightning_wallet` returned early without updating `latest_lightning_wallet_sync_timestamp` when no scripts were registered, causing `wait_for_cbf_sync` to hang on start/stop/reinit cycles. Fold the empty-scripts branch into the main path so both share a single `update_node_metrics_timestamp` site at the end of the closure. Co-Authored-By: Claude Opus 4.7 <[email protected]>
1 parent 20ec7a3 commit 187b18d

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

src/chain/cbf.rs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -730,35 +730,34 @@ impl CbfChainSource {
730730
let scripts: Vec<ScriptBuf> = self.registered_scripts.lock().unwrap().clone();
731731
if scripts.is_empty() {
732732
log_debug!(self.logger, "No registered scripts for CBF lightning sync.");
733-
return Ok(());
734-
}
735-
736-
let timeout_fut = tokio::time::timeout(
737-
Duration::from_secs(
738-
self.sync_config.timeouts_config.lightning_wallet_sync_timeout_secs,
739-
),
740-
self.sync_lightning_wallet_op(
741-
requester,
742-
channel_manager,
743-
chain_monitor,
744-
output_sweeper,
745-
scripts,
746-
),
747-
);
733+
} else {
734+
let timeout_fut = tokio::time::timeout(
735+
Duration::from_secs(
736+
self.sync_config.timeouts_config.lightning_wallet_sync_timeout_secs,
737+
),
738+
self.sync_lightning_wallet_op(
739+
requester,
740+
channel_manager,
741+
chain_monitor,
742+
output_sweeper,
743+
scripts,
744+
),
745+
);
748746

749-
match timeout_fut.await {
750-
Ok(res) => res?,
751-
Err(e) => {
752-
log_error!(self.logger, "Sync of Lightning wallet timed out: {}", e);
753-
return Err(Error::TxSyncTimeout);
754-
},
755-
};
747+
match timeout_fut.await {
748+
Ok(res) => res?,
749+
Err(e) => {
750+
log_error!(self.logger, "Sync of Lightning wallet timed out: {}", e);
751+
return Err(Error::TxSyncTimeout);
752+
},
753+
};
756754

757-
log_debug!(
758-
self.logger,
759-
"Sync of Lightning wallet via CBF finished in {}ms.",
760-
now.elapsed().as_millis()
761-
);
755+
log_debug!(
756+
self.logger,
757+
"Sync of Lightning wallet via CBF finished in {}ms.",
758+
now.elapsed().as_millis()
759+
);
760+
}
762761

763762
update_node_metrics_timestamp(
764763
&self.node_metrics,

0 commit comments

Comments
 (0)