Trait lightning_block_sync::BlockSource[][src]

pub trait BlockSource: Sync + Send {
    fn get_header<'a>(
        &'a mut self,
        header_hash: &'a BlockHash,
        height_hint: Option<u32>
    ) -> AsyncBlockSourceResult<'a, BlockHeaderData>;
fn get_block<'a>(
        &'a mut self,
        header_hash: &'a BlockHash
    ) -> AsyncBlockSourceResult<'a, Block>;
fn get_best_block<'a>(
        &'a mut self
    ) -> AsyncBlockSourceResult<'_, (BlockHash, Option<u32>)>; }
Expand description

Abstract type for retrieving block headers and data.

Required methods

Returns the header for a given hash. A height hint may be provided in case a block source cannot easily find headers based on a hash. This is merely a hint and thus the returned header must have the same hash as was requested. Otherwise, an error must be returned.

Implementations that cannot find headers based on the hash should return a Transient error when height_hint is None.

Returns the block for a given hash. A headers-only block source should return a Transient error.

Returns the hash of the best block and, optionally, its height.

When polling a block source, Poll implementations may pass the height to get_header to allow for a more efficient lookup.

Implementors