introduce a method for fetching relay chain header to RelayChainInterface (#2794)

* introduce a method for fetching header to RelayChainInterface

* cargo fmt

* return Option<Header>
This commit is contained in:
Web3 Philosopher
2023-07-04 16:27:31 +02:00
committed by GitHub
parent 7f2238a218
commit 9c183893ae
5 changed files with 60 additions and 4 deletions
@@ -26,6 +26,7 @@ use jsonrpsee_core::Error as JsonRpcError;
use parity_scale_codec::Error as CodecError;
use sp_api::ApiError;
use cumulus_primitives_core::relay_chain::BlockId;
pub use cumulus_primitives_core::{
relay_chain::{
CommittedCandidateReceipt, Hash as PHash, Header as PHeader, InboundHrmpMessage,
@@ -110,6 +111,9 @@ pub trait RelayChainInterface: Send + Sync {
/// Get the hash of the current best block.
async fn best_block_hash(&self) -> RelayChainResult<PHash>;
/// Fetch the block header of a given height
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>>;
/// Get the hash of the finalized block.
async fn finalized_block_hash(&self) -> RelayChainResult<PHash>;
@@ -293,4 +297,8 @@ where
) -> RelayChainResult<Pin<Box<dyn Stream<Item = PHeader> + Send>>> {
(**self).new_best_notification_stream().await
}
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
(**self).header(block_id).await
}
}