cuprate_p2p::block_downloader

Function download_blocks

Source
pub fn download_blocks<N: NetworkZone, C>(
    peer_set: BoxCloneService<PeerSetRequest, PeerSetResponse<N>, BoxError>,
    our_chain_svc: C,
    config: BlockDownloaderConfig,
) -> BufferStream<BlockBatch>
where C: Service<ChainSvcRequest, Response = ChainSvcResponse, Error = BoxError> + Send + 'static, C::Future: Send + 'static,
Expand description

This function starts the block downloader and returns a BufferStream that will produce a sequential stream of blocks.

The block downloader will pick the longest chain and will follow it for as long as possible, the blocks given from the BufferStream will be in order.

The block downloader may fail before the whole chain is downloaded. If this is the case you can call this function again, so it can start the search again.