reth_network_p2p::headers::downloader

Trait HeaderDownloader

Source
pub trait HeaderDownloader:
    Send
    + Sync
    + Stream<Item = HeadersDownloaderResult<Vec<SealedHeader<Self::Header>>, Self::Header>>
    + Unpin {
    type Header: 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§

Source

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

The header type being downloaded.

Required Methods§

Source

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

Updates the block number of the local database

Source

fn update_sync_target(&mut self, target: SyncTarget)

Updates the target we want to sync to

Source

fn set_batch_size(&mut self, limit: usize)

Sets the headers batch size that the Stream should return.

Provided Methods§

Source

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

Implementors§

Source§

impl HeaderDownloader for TestHeaderDownloader

Available on crate feature test-utils only.
Source§

type Header = Header