mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 21:31:02 +00:00
Simplify runtime api error handling (#8114)
* Ahh * Work work work * Fix all the compilation errors * Fix test * More fixes...
This commit is contained in:
@@ -480,7 +480,7 @@ where
|
||||
Block: BlockT,
|
||||
BE: Backend<Block>,
|
||||
C: crate::ClientForGrandpa<Block, BE>,
|
||||
C::Api: GrandpaApi<Block, Error = sp_blockchain::Error>,
|
||||
C::Api: GrandpaApi<Block>,
|
||||
N: NetworkT<Block>,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
{
|
||||
@@ -549,7 +549,7 @@ where
|
||||
authority_set.set_id,
|
||||
equivocation.offender().clone(),
|
||||
)
|
||||
.map_err(Error::Client)?
|
||||
.map_err(Error::RuntimeApi)?
|
||||
{
|
||||
Some(proof) => proof,
|
||||
None => {
|
||||
@@ -571,7 +571,7 @@ where
|
||||
equivocation_proof,
|
||||
key_owner_proof,
|
||||
)
|
||||
.map_err(Error::Client)?;
|
||||
.map_err(Error::RuntimeApi)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -726,7 +726,7 @@ where
|
||||
Block: 'static,
|
||||
B: Backend<Block>,
|
||||
C: crate::ClientForGrandpa<Block, B> + 'static,
|
||||
C::Api: GrandpaApi<Block, Error = sp_blockchain::Error>,
|
||||
C::Api: GrandpaApi<Block>,
|
||||
N: NetworkT<Block> + 'static + Send + Sync,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
VR: VotingRule<Block, C>,
|
||||
|
||||
@@ -663,6 +663,7 @@ where
|
||||
Error::Safety(error) => ConsensusError::ClientImport(error),
|
||||
Error::Signing(error) => ConsensusError::ClientImport(error),
|
||||
Error::Timer(error) => ConsensusError::ClientImport(error.to_string()),
|
||||
Error::RuntimeApi(error) => ConsensusError::ClientImport(error.to_string()),
|
||||
});
|
||||
},
|
||||
Ok(_) => {
|
||||
|
||||
@@ -295,6 +295,8 @@ pub enum Error {
|
||||
Safety(String),
|
||||
/// A timer failed to fire.
|
||||
Timer(io::Error),
|
||||
/// A runtime api request failed.
|
||||
RuntimeApi(sp_api::ApiError),
|
||||
}
|
||||
|
||||
impl From<GrandpaError> for Error {
|
||||
@@ -698,7 +700,7 @@ where
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
DigestFor<Block>: Encode,
|
||||
C: ClientForGrandpa<Block, BE> + 'static,
|
||||
C::Api: GrandpaApi<Block, Error = sp_blockchain::Error>,
|
||||
C::Api: GrandpaApi<Block>,
|
||||
{
|
||||
let GrandpaParams {
|
||||
mut config,
|
||||
@@ -824,7 +826,7 @@ where
|
||||
Block: BlockT,
|
||||
B: Backend<Block> + 'static,
|
||||
C: ClientForGrandpa<Block, B> + 'static,
|
||||
C::Api: GrandpaApi<Block, Error = sp_blockchain::Error>,
|
||||
C::Api: GrandpaApi<Block>,
|
||||
N: NetworkT<Block> + Sync,
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
@@ -1042,7 +1044,7 @@ where
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
C: ClientForGrandpa<Block, B> + 'static,
|
||||
C::Api: GrandpaApi<Block, Error = sp_blockchain::Error>,
|
||||
C::Api: GrandpaApi<Block>,
|
||||
VR: VotingRule<Block, C> + Clone + 'static,
|
||||
{
|
||||
type Output = Result<(), Error>;
|
||||
|
||||
@@ -174,8 +174,6 @@ impl ProvideRuntimeApi<Block> for TestApi {
|
||||
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl GrandpaApi<Block> for RuntimeApi {
|
||||
type Error = sp_blockchain::Error;
|
||||
|
||||
fn grandpa_authorities(&self) -> AuthorityList {
|
||||
self.inner.genesis_authorities.clone()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user