diff --git a/mutiny-core/src/node.rs b/mutiny-core/src/node.rs index c7c32b149..c32242033 100644 --- a/mutiny-core/src/node.rs +++ b/mutiny-core/src/node.rs @@ -1446,11 +1446,15 @@ impl Node { if self.stop.load(Ordering::Relaxed) { return Err(MutinyError::NotRunning); } - if !self.channel_manager.list_usable_channels().is_empty() - && self.has_done_initial_sync.load(Ordering::SeqCst) - { + let has_usable = !self.channel_manager.list_usable_channels().is_empty(); + let init = self.has_done_initial_sync.load(Ordering::Relaxed); + if has_usable && init { break; } + log_trace!( + self.logger, + "waiting for channel to be usable, has usable channels: {has_usable} finished init sync:{init}" + ); sleep(1_000).await; } diff --git a/mutiny-core/src/nodemanager.rs b/mutiny-core/src/nodemanager.rs index 53492e18f..d723c1889 100644 --- a/mutiny-core/src/nodemanager.rs +++ b/mutiny-core/src/nodemanager.rs @@ -377,6 +377,8 @@ impl NodeManagerBuilder { start.elapsed().as_millis() ); + let has_done_initial_ldk_sync = Arc::new(AtomicBool::new(false)); + let nodes = if c.safe_mode { // If safe mode is enabled, we don't start any nodes log_warn!(logger, "Safe mode enabled, not starting any nodes"); @@ -404,6 +406,7 @@ impl NodeManagerBuilder { .with_fee_estimator(fee_estimator.clone()) .with_wallet(wallet.clone()) .with_esplora(esplora.clone()) + .with_initial_sync(has_done_initial_ldk_sync.clone()) .with_network(c.network); node_builder.with_logger(logger.clone()); @@ -491,7 +494,7 @@ impl NodeManagerBuilder { logger, do_not_connect_peers: c.do_not_connect_peers, safe_mode: c.safe_mode, - has_done_initial_ldk_sync: Arc::new(AtomicBool::new(false)), + has_done_initial_ldk_sync, }; Ok(nm)