;
}
/// Substrate finality proof. Specific to the used `FinalityEngine`.
pub type SubstrateFinalityProof = <
::FinalityEngine as Engine<
::SourceChain,
>>::FinalityProof;
/// Substrate finality proofs stream.
pub type SubstrateFinalityProofsStream
=
Pin> + Send>>;
/// Subscribe to new finality proofs.
pub async fn finality_proofs(
client: &Client,
) -> Result, Error> {
Ok(unfold(
P::FinalityEngine::source_finality_proofs(client).await?,
move |subscription| async move {
loop {
let log_error = |err| {
log::error!(
target: "bridge",
"Failed to read justification target from the {} justifications stream: {:?}",
P::SourceChain::NAME,
err,
);
};
let next_justification =
subscription.next().await.map_err(|err| log_error(err.to_string())).ok()??;
let decoded_justification =
>::FinalityProof::decode(
&mut &next_justification[..],
);
let justification = match decoded_justification {
Ok(j) => j,
Err(err) => {
log_error(format!("decode failed with error {err:?}"));
continue
},
};
return Some((justification, subscription))
}
},
)
.boxed())
}