Function zebra_consensus::router::init

source ·
pub async fn init<S, Mempool>(
    config: Config,
    network: &Network,
    state_service: S,
    mempool: Receiver<Mempool>,
) -> (Buffer<BoxService<Request, Hash, RouterError>, Request>, Buffer<BoxService<Request, Response, TransactionError>, Request>, BackgroundTaskHandles, Height)
where S: Service<Request, Response = Response, Error = BoxError> + Send + Clone + 'static, S::Future: Send + 'static, Mempool: Service<Request, Response = Response, Error = BoxError> + Send + Clone + 'static, Mempool::Future: Send + 'static,
Expand description

Initialize block and transaction verification services.

Returns a block verifier, transaction verifier, a BackgroundTaskHandles with the state checkpoint verify task, and the maximum configured checkpoint verification height.

The consensus configuration is specified by config, and the Zcash network to verify blocks for is specified by network.

The block verification service asynchronously performs semantic verification checks. Blocks that pass semantic verification are submitted to the supplied state_service for contextual verification before being committed to the chain.

The transaction verification service asynchronously performs semantic verification checks. Transactions that pass semantic verification return an Ok result to the caller.

This function should only be called once for a particular state service.

Dropped requests are cancelled on a best-effort basis, but may continue to be processed.

§Correctness

Block and transaction verification requests should be wrapped in a timeout, so that out-of-order and invalid requests do not hang indefinitely. See the router module documentation for details.