Trait HeadersClient

pub trait HeadersClient: DownloadClient {
    type Header: BlockHeader;
    type Output: Future<Output = Result<WithPeerId<Vec<Self::Header>>, RequestError>> + Sync + Send + Unpin;

    // Required method
    fn get_headers_with_priority(
        &self,
        request: HeadersRequest,
        priority: Priority,
    ) -> Self::Output;

    // Provided methods
    fn get_headers(&self, request: HeadersRequest) -> Self::Output { ... }
    fn get_header(
        &self,
        start: HashOrNumber,
    ) -> SingleHeaderRequest<Self::Output>  { ... }
    fn get_header_with_priority(
        &self,
        start: HashOrNumber,
        priority: Priority,
    ) -> SingleHeaderRequest<Self::Output>  { ... }
}
Expand description

The block headers downloader client

Required Associated Types§

type Header: BlockHeader

The header type this client fetches.

type Output: Future<Output = Result<WithPeerId<Vec<Self::Header>>, RequestError>> + Sync + Send + Unpin

The headers future type

Required Methods§

fn get_headers_with_priority( &self, request: HeadersRequest, priority: Priority, ) -> Self::Output

Sends the header request to the p2p network with priority set and returns the header response received from a peer.

Provided Methods§

fn get_headers(&self, request: HeadersRequest) -> Self::Output

Sends the header request to the p2p network and returns the header response received from a peer.

fn get_header(&self, start: HashOrNumber) -> SingleHeaderRequest<Self::Output>

Fetches a single header for the requested number or hash.

fn get_header_with_priority( &self, start: HashOrNumber, priority: Priority, ) -> SingleHeaderRequest<Self::Output>

Fetches a single header for the requested number or hash with priority

Implementations on Foreign Types§

§

impl<'a, T> HeadersClient for &'a T

Source§

impl<B> HeadersClient for FileClient<B>
where B: FullBlock,

Source§

type Header = <B as Block>::Header

Source§

type Output = Pin<Box<dyn Future<Output = Result<WithPeerId<Vec<<B as Block>::Header>>, RequestError>> + Send + Sync>>

Source§

fn get_headers_with_priority( &self, request: HeadersRequest, _priority: Priority, ) -> <FileClient<B> as HeadersClient>::Output

§

impl<T> HeadersClient for Box<T>

§

impl<T> HeadersClient for Arc<T>

Implementors§

§

impl HeadersClient for NoopFullBlockClient

§

type Header = Header

§

type Output = Ready<Result<WithPeerId<Vec<Header>>, RequestError>>

§

impl HeadersClient for TestFullBlockClient

Implements the HeadersClient trait for the TestFullBlockClient struct.

§

type Header = Header

§

type Output = Ready<Result<WithPeerId<Vec<Header>>, RequestError>>

§

impl HeadersClient for TestHeadersClient

§

type Header = Header

§

type Output = Pin<Box<dyn Future<Output = Result<WithPeerId<Vec<Header>>, RequestError>> + Send + Sync>>

§

impl<A, B> HeadersClient for Either<A, B>
where A: HeadersClient, B: HeadersClient<Header = <A as HeadersClient>::Header>,

Source§

impl<N> HeadersClient for FetchClient<N>