add leaves function to chain (#1154)

This commit is contained in:
Robert Habermeier
2018-11-23 02:35:01 +01:00
committed by GitHub
parent 41aec063df
commit 2e41e9e870
+7
View File
@@ -93,6 +93,9 @@ pub trait BlockchainEvents<Block: BlockT> {
pub trait ChainHead<Block: BlockT> {
/// Get best block header.
fn best_block_header(&self) -> Result<<Block as BlockT>::Header, error::Error>;
/// Get all leaves of the chain: block hashes that have no children currently.
/// Leaves that can never be finalized will not be returned.
fn leaves(&self) -> Result<Vec<<Block as BlockT>::Hash>, error::Error>;
}
/// Fetch block body by ID.
@@ -1189,6 +1192,10 @@ where
fn best_block_header(&self) -> error::Result<<Block as BlockT>::Header> {
Client::best_block_header(self)
}
fn leaves(&self) -> Result<Vec<<Block as BlockT>::Hash>, error::Error> {
self.backend.blockchain().leaves()
}
}
impl<B, E, Block, RA> BlockBody<Block> for Client<B, E, Block, RA>