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>
    ) -> Pin<Box<dyn Future<Output = Result<BlockHeaderData, BlockSourceError>> + Send + 'a>>;
fn get_block<'a>(
        &'a mut self,
        header_hash: &'a BlockHash
    ) -> Pin<Box<dyn Future<Output = Result<Block, BlockSourceError>> + Send + 'a>>;
fn get_best_block<'a>(
        &'a mut self
    ) -> Pin<Box<dyn Future<Output = Result<(BlockHash, Option<u32>), BlockSourceError>> + Send + '_>>; }

Abstract type for retrieving block headers and data.

Required methods

fn get_header<'a>(
    &'a mut self,
    header_hash: &'a BlockHash,
    height_hint: Option<u32>
) -> Pin<Box<dyn Future<Output = Result<BlockHeaderData, BlockSourceError>> + Send + 'a>>
[src]

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.

fn get_block<'a>(
    &'a mut self,
    header_hash: &'a BlockHash
) -> Pin<Box<dyn Future<Output = Result<Block, BlockSourceError>> + Send + 'a>>
[src]

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

fn get_best_block<'a>(
    &'a mut self
) -> Pin<Box<dyn Future<Output = Result<(BlockHash, Option<u32>), BlockSourceError>> + Send + '_>>
[src]

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.

Loading content...

Implementors

Loading content...