Skip to main content

HeaderClient

Trait HeaderClient 

Source
pub trait HeaderClient: ClientT {
    // Provided methods
    fn header_get_by_hash<'a, 'fut>(
        &'a self,
        hash: Hash,
    ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
       where Self: Sized + Sync + 'fut,
             'a: 'fut { ... }
    fn header_get_by_height<'a, 'fut>(
        &'a self,
        height: u64,
    ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
       where Self: Sized + Sync + 'fut,
             'a: 'fut { ... }
    fn header_get_range_by_height<'a, 'b, 'fut>(
        &'a self,
        from: ExtendedHeader,
        to: u64,
    ) -> impl Future<Output = Result<Vec<ExtendedHeader>, Error>> + Send + 'fut
       where Self: Sized + Sync + 'fut,
             'a: 'fut,
             'b: 'fut { ... }
    fn header_local_head<'a, 'fut>(
        &'a self,
    ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
       where Self: Sized + Sync + 'fut,
             'a: 'fut { ... }
    fn header_network_head<'a, 'fut>(
        &'a self,
    ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
       where Self: Sized + Sync + 'fut,
             'a: 'fut { ... }
    fn header_subscribe<'a>(
        &'a self,
    ) -> Pin<Box<dyn Stream<Item = Result<ExtendedHeader, Error>> + Send + 'a>>
       where Self: SubscriptionClientT + Sized + Sync { ... }
    fn header_sync_state<'a, 'fut>(
        &'a self,
    ) -> impl Future<Output = Result<SyncState, Error>> + Send + 'fut
       where Self: Sized + Sync + 'fut,
             'a: 'fut { ... }
    fn header_sync_wait<'a, 'fut>(
        &'a self,
    ) -> impl Future<Output = Result<(), Error>> + Send + 'fut
       where Self: Sized + Sync + 'fut,
             'a: 'fut { ... }
    fn header_wait_for_height<'a, 'fut>(
        &'a self,
        height: u64,
    ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
       where Self: Sized + Sync + 'fut,
             'a: 'fut { ... }
}
Expand description

Client implementation for the Header RPC API.

Provided Methods§

Source

fn header_get_by_hash<'a, 'fut>( &'a self, hash: Hash, ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
where Self: Sized + Sync + 'fut, 'a: 'fut,

GetByHash returns the header of the given hash from the node’s header store.

Source

fn header_get_by_height<'a, 'fut>( &'a self, height: u64, ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
where Self: Sized + Sync + 'fut, 'a: 'fut,

GetByHeight returns the ExtendedHeader at the given height if it is currently available.

Source

fn header_get_range_by_height<'a, 'b, 'fut>( &'a self, from: ExtendedHeader, to: u64, ) -> impl Future<Output = Result<Vec<ExtendedHeader>, Error>> + Send + 'fut
where Self: Sized + Sync + 'fut, 'a: 'fut, 'b: 'fut,

GetRangeByHeight returns the given range (from:to) of ExtendedHeaders from the node’s header store and verifies that the returned headers are adjacent to each other.

Source

fn header_local_head<'a, 'fut>( &'a self, ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
where Self: Sized + Sync + 'fut, 'a: 'fut,

LocalHead returns the ExtendedHeader of the chain head.

Source

fn header_network_head<'a, 'fut>( &'a self, ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
where Self: Sized + Sync + 'fut, 'a: 'fut,

NetworkHead provides the Syncer’s view of the current network head.

Source

fn header_subscribe<'a>( &'a self, ) -> Pin<Box<dyn Stream<Item = Result<ExtendedHeader, Error>> + Send + 'a>>
where Self: SubscriptionClientT + Sized + Sync,

Subscribe to recent ExtendedHeaders from the network.

§Notes

If client returns Error::HttpNotImplemented, the subscription will fallback to using HeaderClient::header_wait_for_height for streaming the headers.

Source

fn header_sync_state<'a, 'fut>( &'a self, ) -> impl Future<Output = Result<SyncState, Error>> + Send + 'fut
where Self: Sized + Sync + 'fut, 'a: 'fut,

SyncState returns the current state of the header Syncer.

Source

fn header_sync_wait<'a, 'fut>( &'a self, ) -> impl Future<Output = Result<(), Error>> + Send + 'fut
where Self: Sized + Sync + 'fut, 'a: 'fut,

SyncWait blocks until the header Syncer is synced to network head.

Source

fn header_wait_for_height<'a, 'fut>( &'a self, height: u64, ) -> impl Future<Output = Result<ExtendedHeader, Error>> + Send + 'fut
where Self: Sized + Sync + 'fut, 'a: 'fut,

WaitForHeight blocks until the header at the given height has been processed by the store or context deadline is exceeded.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> HeaderClient for T
where T: ClientT,