Skip to content

Commit

Permalink
Use correct initial sync AtomicBool
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Apr 18, 2024
1 parent cc14c84 commit 414c6a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions mutiny-core/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,11 +1446,15 @@ impl<S: MutinyStorage> Node<S> {
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;
}

Expand Down
5 changes: 4 additions & 1 deletion mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ impl<S: MutinyStorage> NodeManagerBuilder<S> {
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");
Expand Down Expand Up @@ -404,6 +406,7 @@ impl<S: MutinyStorage> NodeManagerBuilder<S> {
.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());

Expand Down Expand Up @@ -491,7 +494,7 @@ impl<S: MutinyStorage> NodeManagerBuilder<S> {
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)
Expand Down

0 comments on commit 414c6a7

Please sign in to comment.