zebra_scan/service/
scan_task.rsuse std::sync::Arc;
use color_eyre::Report;
use tokio::task::JoinHandle;
use zebra_state::ChainTipChange;
use crate::storage::Storage;
mod commands;
mod executor;
pub mod scan;
pub use commands::ScanTaskCommand;
#[cfg(any(test, feature = "proptest-impl"))]
pub mod tests;
#[derive(Debug, Clone)]
pub struct ScanTask {
pub handle: Arc<JoinHandle<Result<(), Report>>>,
pub cmd_sender: tokio::sync::mpsc::Sender<ScanTaskCommand>,
}
const SCAN_TASK_BUFFER_SIZE: usize = 100;
impl ScanTask {
pub fn spawn(db: Storage, state: scan::State, chain_tip_change: ChainTipChange) -> Self {
let (cmd_sender, cmd_receiver) = tokio::sync::mpsc::channel(SCAN_TASK_BUFFER_SIZE);
Self {
handle: Arc::new(scan::spawn_init(db, state, chain_tip_change, cmd_receiver)),
cmd_sender,
}
}
}