Skip to content

Commit 670d952

Browse files
committed
f: Stop chain source after *all* startup failures
Co-Authored-By: HAL 9000
1 parent 05efb2f commit 670d952

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,16 @@ impl Node {
292292
return Err(Error::AlreadyRunning);
293293
}
294294

295+
match self.start_inner(&mut is_running_lock) {
296+
Ok(()) => Ok(()),
297+
Err(e) => {
298+
self.chain_source.stop();
299+
Err(e)
300+
},
301+
}
302+
}
303+
304+
fn start_inner(&self, is_running_lock: &mut bool) -> Result<(), Error> {
295305
log_info!(
296306
self.logger,
297307
"Starting up LDK Node with node ID {} on network: {}",
@@ -336,18 +346,14 @@ impl Node {
336346
//
337347
// TODO: drop 0FC chain source validation when support is ubiquitous
338348
let chain_source = Arc::clone(&self.chain_source);
339-
let startup_chain_check_res = self.runtime.block_on(async move {
349+
self.runtime.block_on(async move {
340350
tokio::try_join!(
341351
chain_source.update_fee_rate_estimates(),
342352
chain_source.validate_zero_fee_commitments_support_if_required(
343353
zero_fee_commitments_support_required
344354
)
345355
)
346-
});
347-
if let Err(e) = startup_chain_check_res {
348-
self.chain_source.stop();
349-
return Err(e);
350-
}
356+
})?;
351357

352358
// Spawn background task continuously syncing onchain, lightning, and fee rate cache.
353359
let stop_sync_receiver = self.stop_sender.subscribe();

0 commit comments

Comments
 (0)