Skip to content

Commit

Permalink
fix the task handler
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Nov 24, 2023
1 parent 404236e commit cd8b0fd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions zebrad/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Result<(), Report>> =
tokio::spawn(std::future::pending().in_current_span());

info!("spawned initial Zebra tasks");

Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit cd8b0fd

Please sign in to comment.