mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 13:21:10 +00:00
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:
@@ -16,6 +16,7 @@
|
||||
|
||||
use super::*;
|
||||
use async_trait::async_trait;
|
||||
use cumulus_primitives_core::relay_chain::BlockId;
|
||||
use cumulus_relay_chain_inprocess_interface::{check_block_in_chain, BlockCheckStatus};
|
||||
use cumulus_relay_chain_interface::{
|
||||
OverseerHandle, PHeader, ParaId, RelayChainError, RelayChainResult,
|
||||
@@ -237,6 +238,18 @@ impl RelayChainInterface for DummyRelayChainInterface {
|
||||
});
|
||||
Ok(Box::pin(notifications_stream))
|
||||
}
|
||||
|
||||
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
|
||||
let hash = match block_id {
|
||||
BlockId::Hash(hash) => hash,
|
||||
BlockId::Number(num) => self.relay_client.hash(num)?.ok_or_else(|| {
|
||||
RelayChainError::GenericError(format!("block with number {num} not found"))
|
||||
})?,
|
||||
};
|
||||
let header = self.relay_client.header(hash)?;
|
||||
|
||||
Ok(header)
|
||||
}
|
||||
}
|
||||
|
||||
fn make_validator_and_api(
|
||||
|
||||
Reference in New Issue
Block a user