pub trait BlockDownloader<Block: BlockT>:
    Debug
    + Send
    + Sync {
    // Required methods
    fn protocol_name(&self) -> &ProtocolName;
    fn download_blocks<'life0, 'async_trait>(
        &'life0 self,
        who: PeerId,
        request: BlockRequest<Block>,
    ) -> Pin<Box<dyn Future<Output = Result<Result<(Vec<u8>, ProtocolName), RequestFailure>, Canceled>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn block_response_into_blocks(
        &self,
        request: &BlockRequest<Block>,
        response: Vec<u8>,
    ) -> Result<Vec<BlockData<Block>>, BlockResponseError>;
}Expand description
The client side stub to download blocks from peers. This is a handle that can be used to initiate concurrent downloads.
Required Methods§
Sourcefn protocol_name(&self) -> &ProtocolName
 
fn protocol_name(&self) -> &ProtocolName
Protocol name used by block downloader.
Sourcefn download_blocks<'life0, 'async_trait>(
    &'life0 self,
    who: PeerId,
    request: BlockRequest<Block>,
) -> Pin<Box<dyn Future<Output = Result<Result<(Vec<u8>, ProtocolName), RequestFailure>, Canceled>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
 
fn download_blocks<'life0, 'async_trait>(
    &'life0 self,
    who: PeerId,
    request: BlockRequest<Block>,
) -> Pin<Box<dyn Future<Output = Result<Result<(Vec<u8>, ProtocolName), RequestFailure>, Canceled>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
Performs the protocol specific sequence to fetch the blocks from the peer.
Output: if the download succeeds, the response is a Vec<u8> which is
in a format specific to the protocol implementation. The block data
can be extracted from this response using BlockDownloader::block_response_into_blocks.
Sourcefn block_response_into_blocks(
    &self,
    request: &BlockRequest<Block>,
    response: Vec<u8>,
) -> Result<Vec<BlockData<Block>>, BlockResponseError>
 
fn block_response_into_blocks( &self, request: &BlockRequest<Block>, response: Vec<u8>, ) -> Result<Vec<BlockData<Block>>, BlockResponseError>
Parses the protocol specific response to retrieve the block data.