reth_network_p2p::headers::client

Trait HeadersClient

Source
pub trait HeadersClient: DownloadClient {
    type Header: Send + Sync + Unpin;
    type Output: Future<Output = PeerRequestResult<Vec<Self::Header>>> + 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: BlockHashOrNumber,
    ) -> SingleHeaderRequest<Self::Output>  { ... }
    fn get_header_with_priority(
        &self,
        start: BlockHashOrNumber,
        priority: Priority,
    ) -> SingleHeaderRequest<Self::Output>  { ... }
}
Expand description

The block headers downloader client

Required Associated Types§

Source

type Header: Send + Sync + Unpin

The header type this client fetches.

Source

type Output: Future<Output = PeerRequestResult<Vec<Self::Header>>> + Sync + Send + Unpin

The headers future type

Required Methods§

Source

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§

Source

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.

Source

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

Fetches a single header for the requested number or hash.

Source

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

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

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + HeadersClient + ?Sized> HeadersClient for &'a T

Source§

type Header = <T as HeadersClient>::Header

Source§

type Output = <T as HeadersClient>::Output

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: HeadersClient + ?Sized> HeadersClient for Box<T>
where Box<T>: DownloadClient,

Source§

type Header = <T as HeadersClient>::Header

Source§

type Output = <T as HeadersClient>::Output

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: HeadersClient + ?Sized> HeadersClient for Arc<T>
where Arc<T>: DownloadClient,

Source§

type Header = <T as HeadersClient>::Header

Source§

type Output = <T as HeadersClient>::Output

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl HeadersClient for NoopFullBlockClient

Available on crate feature test-utils only.
Source§

type Header = Header

Source§

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

Source§

impl HeadersClient for TestFullBlockClient

Available on crate feature test-utils only.

Implements the HeadersClient trait for the TestFullBlockClient struct.

Source§

type Header = Header

Source§

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

Source§

impl HeadersClient for TestHeadersClient

Available on crate feature test-utils only.
Source§

type Header = Header

Source§

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

Source§

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