mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
Avoid Panic When Fetching Info Before Bridge is Initialized (#504)
* Allow bridge pallet to return no finalized headers * Update Runtime APIs to optionally return best finalized header * Update relay to handle optional best finalized headers * Fix Clippy lints * Return a dummy header instead of an Option * Remove Option from runtime Apis * Remove support for handling optional finalized headers in relay
This commit is contained in:
committed by
Bastian Köcher
parent
595523106e
commit
e91cab68d4
@@ -91,13 +91,12 @@ where
|
||||
let decoded_response: Vec<(P::Number, P::Hash)> =
|
||||
Decode::decode(&mut &encoded_response.0[..]).map_err(SubstrateError::ResponseParseFailed)?;
|
||||
|
||||
const WARNING_MSG: &str = "Parsed an empty list of headers, we should always have at least
|
||||
one. Has the bridge pallet been initialized yet?";
|
||||
let best_header = decoded_response
|
||||
// If we parse an empty list of headers it means that bridge pallet has not been initalized
|
||||
// yet. Otherwise we expect to always have at least one header.
|
||||
decoded_response
|
||||
.last()
|
||||
.ok_or_else(|| SubstrateError::ResponseParseFailed(WARNING_MSG.into()))?;
|
||||
let best_header_id = HeaderId(best_header.0, best_header.1);
|
||||
Ok(best_header_id)
|
||||
.ok_or(SubstrateError::UninitializedBridgePallet)
|
||||
.map(|(num, hash)| HeaderId(*num, *hash))
|
||||
}
|
||||
|
||||
async fn is_known_header(&self, id: HeaderIdOf<P>) -> Result<(HeaderIdOf<P>, bool), Self::Error> {
|
||||
|
||||
Reference in New Issue
Block a user