Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit b3ac5d6

Browse files
Merge pull request #1150 from MutinyWallet/fix-init-sync
Use correct initial sync AtomicBool
2 parents d7fc568 + 414c6a7 commit b3ac5d6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

mutiny-core/src/node.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,11 +1446,15 @@ impl<S: MutinyStorage> Node<S> {
14461446
if self.stop.load(Ordering::Relaxed) {
14471447
return Err(MutinyError::NotRunning);
14481448
}
1449-
if !self.channel_manager.list_usable_channels().is_empty()
1450-
&& self.has_done_initial_sync.load(Ordering::SeqCst)
1451-
{
1449+
let has_usable = !self.channel_manager.list_usable_channels().is_empty();
1450+
let init = self.has_done_initial_sync.load(Ordering::Relaxed);
1451+
if has_usable && init {
14521452
break;
14531453
}
1454+
log_trace!(
1455+
self.logger,
1456+
"waiting for channel to be usable, has usable channels: {has_usable} finished init sync:{init}"
1457+
);
14541458
sleep(1_000).await;
14551459
}
14561460

mutiny-core/src/nodemanager.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ impl<S: MutinyStorage> NodeManagerBuilder<S> {
377377
start.elapsed().as_millis()
378378
);
379379

380+
let has_done_initial_ldk_sync = Arc::new(AtomicBool::new(false));
381+
380382
let nodes = if c.safe_mode {
381383
// If safe mode is enabled, we don't start any nodes
382384
log_warn!(logger, "Safe mode enabled, not starting any nodes");
@@ -404,6 +406,7 @@ impl<S: MutinyStorage> NodeManagerBuilder<S> {
404406
.with_fee_estimator(fee_estimator.clone())
405407
.with_wallet(wallet.clone())
406408
.with_esplora(esplora.clone())
409+
.with_initial_sync(has_done_initial_ldk_sync.clone())
407410
.with_network(c.network);
408411
node_builder.with_logger(logger.clone());
409412

@@ -491,7 +494,7 @@ impl<S: MutinyStorage> NodeManagerBuilder<S> {
491494
logger,
492495
do_not_connect_peers: c.do_not_connect_peers,
493496
safe_mode: c.safe_mode,
494-
has_done_initial_ldk_sync: Arc::new(AtomicBool::new(false)),
497+
has_done_initial_ldk_sync,
495498
};
496499

497500
Ok(nm)

0 commit comments

Comments
 (0)