mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
ensure that the bridge GRANDPA pallet is initialized in the finality relay (#1423)
This commit is contained in:
committed by
Bastian Köcher
parent
4001cfb758
commit
78a43c561a
@@ -110,7 +110,11 @@ where
|
||||
}
|
||||
|
||||
/// Returns `Ok(true)` if bridge has already been initialized.
|
||||
async fn is_initialized<E: Engine<SourceChain>, SourceChain: Chain, TargetChain: Chain>(
|
||||
pub(crate) async fn is_initialized<
|
||||
E: Engine<SourceChain>,
|
||||
SourceChain: Chain,
|
||||
TargetChain: Chain,
|
||||
>(
|
||||
target_client: &Client<TargetChain>,
|
||||
) -> Result<bool, Error<HashOf<SourceChain>, BlockNumberOf<SourceChain>>> {
|
||||
Ok(target_client
|
||||
|
||||
@@ -53,10 +53,20 @@ impl<P: SubstrateFinalitySyncPipeline> SubstrateFinalityTarget<P> {
|
||||
pub async fn ensure_pallet_active(&self) -> Result<(), Error> {
|
||||
let is_halted = self.client.storage_value(P::FinalityEngine::is_halted_key(), None).await?;
|
||||
if is_halted.unwrap_or(false) {
|
||||
Err(Error::BridgePalletIsHalted)
|
||||
} else {
|
||||
Ok(())
|
||||
return Err(Error::BridgePalletIsHalted)
|
||||
}
|
||||
|
||||
let is_initialized =
|
||||
super::initialize::is_initialized::<P::FinalityEngine, P::SourceChain, P::TargetChain>(
|
||||
&self.client,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| Error::Custom(e.to_string()))?;
|
||||
if !is_initialized {
|
||||
return Err(Error::BridgePalletIsNotInitialized)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user