From cd8b0fd36845e1f96112bb95b6c6455c03a6a737 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Fri, 24 Nov 2023 15:29:35 -0300 Subject: [PATCH] fix the task handler --- zebrad/src/commands/start.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zebrad/src/commands/start.rs b/zebrad/src/commands/start.rs index 7276c17a396..371d8f2fb0c 100644 --- a/zebrad/src/commands/start.rs +++ b/zebrad/src/commands/start.rs @@ -297,6 +297,10 @@ impl StartCmd { tokio::spawn(zebra_scan::scan::start(state, storage).in_current_span()) }; + #[cfg(not(feature = "zebra-scan"))] + // Spawn a dummy scan task which doesn't do anything and never finishes. + let scan_task_handle: tokio::task::JoinHandle> = + tokio::spawn(std::future::pending().in_current_span()); info!("spawned initial Zebra tasks"); @@ -312,7 +316,6 @@ impl StartCmd { pin!(tx_gossip_task_handle); pin!(progress_task_handle); pin!(end_of_support_task_handle); - #[cfg(feature = "zebra-scan")] pin!(scan_task_handle); // startup tasks @@ -401,7 +404,9 @@ impl StartCmd { Ok(()) } - // TODO: add scan task which is tricky because it needs to be behind a feature. + scan_result = &mut scan_task_handle => scan_result + .expect("unexpected panic in the scan task") + .map(|_| info!("scan task exited")), }; // Stop Zebra if a task finished and returned an error, @@ -427,8 +432,6 @@ impl StartCmd { tx_gossip_task_handle.abort(); progress_task_handle.abort(); end_of_support_task_handle.abort(); - - #[cfg(feature = "zebra-scan")] scan_task_handle.abort(); // startup tasks