Trait HeaderDownloader

pub trait HeaderDownloader:
    Send
    + Sync
    + Stream<Item = Result<Vec<SealedHeader<Self::Header>>, HeadersDownloaderError<Self::Header>>>
    + Unpin {
    type Header: Sealable + Debug + Send + Sync + Unpin + 'static;

    // Required methods
    fn update_local_head(&mut self, head: SealedHeader<Self::Header>);
    fn update_sync_target(&mut self, target: SyncTarget);
    fn set_batch_size(&mut self, limit: usize);

    // Provided method
    fn update_sync_gap(
        &mut self,
        head: SealedHeader<Self::Header>,
        target: SyncTarget,
    ) { ... }
}
Expand description

A downloader capable of fetching and yielding block headers.

A downloader represents a distinct strategy for submitting requests to download block headers, while a HeadersClient represents a client capable of fulfilling these requests.

A HeaderDownloader is a [Stream] that returns batches of headers.

Required Associated Types§

type Header: Sealable + Debug + Send + Sync + Unpin + 'static

The header type being downloaded.

Required Methods§

fn update_local_head(&mut self, head: SealedHeader<Self::Header>)

Updates the block number of the local database

fn update_sync_target(&mut self, target: SyncTarget)

Updates the target we want to sync to.

fn set_batch_size(&mut self, limit: usize)

Sets the headers batch size that the Stream should return.

Provided Methods§

fn update_sync_gap( &mut self, head: SealedHeader<Self::Header>, target: SyncTarget, )

Updates the gap to sync which ranges from local head to the sync target.

See also HeaderDownloader::update_sync_target and HeaderDownloader::update_local_head

Implementations on Foreign Types§

Source§

impl<H> HeaderDownloader for NoopHeaderDownloader<H>
where H: Sealable + Debug + Send + Sync + Unpin + 'static,

Source§

impl<H> HeaderDownloader for ReverseHeadersDownloader<H>
where H: HeadersClient + 'static, <H as HeadersClient>::Header: BlockHeader,

Source§

fn update_sync_target(&mut self, target: SyncTarget)

If the given target is different from the current target, we need to update the sync target

Source§

type Header = <H as HeadersClient>::Header

Source§

fn update_local_head( &mut self, head: SealedHeader<<H as HeadersClient>::Header>, )

Source§

fn set_batch_size(&mut self, batch_size: usize)

Source§

impl<H> HeaderDownloader for TaskDownloader<H>
where H: Sealable + Debug + Send + Sync + Unpin + 'static,

Source§

type Header = H

Source§

fn update_sync_gap(&mut self, head: SealedHeader<H>, target: SyncTarget)

Source§

fn update_local_head(&mut self, head: SealedHeader<H>)

Source§

fn update_sync_target(&mut self, target: SyncTarget)

Source§

fn set_batch_size(&mut self, limit: usize)

Implementors§