pub trait BlockSource: Sync + Send {
// Required methods
fn get_header<'life0, 'life1, 'async_trait>(
&'life0 self,
header_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<BlockHeaderData>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_block<'life0, 'life1, 'async_trait>(
&'life0 self,
header_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<Block>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_block_hash<'life0, 'async_trait>(
&'life0 self,
height: u32,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<Option<BlockHash>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_best_block<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<(BlockHash, u32)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Abstract type for retrieving block headers and data.
Required Methods§
Sourcefn get_header<'life0, 'life1, 'async_trait>(
&'life0 self,
header_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<BlockHeaderData>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_header<'life0, 'life1, 'async_trait>(
&'life0 self,
header_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<BlockHeaderData>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the header for a given hash
Sourcefn get_block<'life0, 'life1, 'async_trait>(
&'life0 self,
header_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<Block>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_block<'life0, 'life1, 'async_trait>(
&'life0 self,
header_hash: &'life1 BlockHash,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<Block>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the block for a given hash.
Sourcefn get_block_hash<'life0, 'async_trait>(
&'life0 self,
height: u32,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<Option<BlockHash>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_block_hash<'life0, 'async_trait>(
&'life0 self,
height: u32,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<Option<BlockHash>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns hash of block in best-block-chain at height provided.
Sourcefn get_best_block<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<(BlockHash, u32)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_best_block<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = BlockSourceResult<(BlockHash, u32)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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.