Trait lightning_block_sync::BlockSource
source · pub trait BlockSource: Sync + Send {
// Required methods
fn get_header<'a>(
&'a self,
header_hash: &'a BlockHash,
height_hint: Option<u32>
) -> AsyncBlockSourceResult<'a, BlockHeaderData>;
fn get_block<'a>(
&'a self,
header_hash: &'a BlockHash
) -> AsyncBlockSourceResult<'a, BlockData>;
fn get_best_block<'a>(
&'a self
) -> AsyncBlockSourceResult<'_, (BlockHash, Option<u32>)>;
}
Expand description
Abstract type for retrieving block headers and data.
Required Methods§
sourcefn get_header<'a>(
&'a self,
header_hash: &'a BlockHash,
height_hint: Option<u32>
) -> AsyncBlockSourceResult<'a, BlockHeaderData>
fn get_header<'a>( &'a self, header_hash: &'a BlockHash, height_hint: Option<u32> ) -> AsyncBlockSourceResult<'a, BlockHeaderData>
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
.
sourcefn get_block<'a>(
&'a self,
header_hash: &'a BlockHash
) -> AsyncBlockSourceResult<'a, BlockData>
fn get_block<'a>( &'a self, header_hash: &'a BlockHash ) -> AsyncBlockSourceResult<'a, BlockData>
Returns the block for a given hash. A headers-only block source should return a Transient
error.
sourcefn get_best_block<'a>(
&'a self
) -> AsyncBlockSourceResult<'_, (BlockHash, Option<u32>)>
fn get_best_block<'a>( &'a self ) -> AsyncBlockSourceResult<'_, (BlockHash, Option<u32>)>
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§
impl BlockSource for RestClient
Available on crate feature
rest-client
only.impl BlockSource for RpcClient
Available on crate feature
rpc-client
only.