mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +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:
@@ -93,7 +93,7 @@ where
|
||||
Block: BlockT + Unpin + 'static,
|
||||
Network: NetworkProvider,
|
||||
Client: ProvideRuntimeApi<Block> + Send + Sync + 'static + HeaderBackend<Block>,
|
||||
<Client as ProvideRuntimeApi<Block>>::Api: AuthorityDiscoveryApi<Block, Error = sp_blockchain::Error>,
|
||||
<Client as ProvideRuntimeApi<Block>>::Api: AuthorityDiscoveryApi<Block>,
|
||||
DhtEventStream: Stream<Item = DhtEvent> + Unpin,
|
||||
{
|
||||
new_worker_and_service_with_config(
|
||||
@@ -121,7 +121,7 @@ where
|
||||
Block: BlockT + Unpin + 'static,
|
||||
Network: NetworkProvider,
|
||||
Client: ProvideRuntimeApi<Block> + Send + Sync + 'static + HeaderBackend<Block>,
|
||||
<Client as ProvideRuntimeApi<Block>>::Api: AuthorityDiscoveryApi<Block, Error = sp_blockchain::Error>,
|
||||
<Client as ProvideRuntimeApi<Block>>::Api: AuthorityDiscoveryApi<Block>,
|
||||
DhtEventStream: Stream<Item = DhtEvent> + Unpin,
|
||||
{
|
||||
let (to_worker, from_service) = mpsc::channel(0);
|
||||
|
||||
@@ -132,7 +132,7 @@ where
|
||||
Network: NetworkProvider,
|
||||
Client: ProvideRuntimeApi<Block> + Send + Sync + 'static + HeaderBackend<Block>,
|
||||
<Client as ProvideRuntimeApi<Block>>::Api:
|
||||
AuthorityDiscoveryApi<Block, Error = sp_blockchain::Error>,
|
||||
AuthorityDiscoveryApi<Block>,
|
||||
DhtEventStream: Stream<Item = DhtEvent> + Unpin,
|
||||
{
|
||||
/// Construct a [`Worker`].
|
||||
@@ -332,7 +332,7 @@ where
|
||||
.client
|
||||
.runtime_api()
|
||||
.authorities(&id)
|
||||
.map_err(Error::CallingRuntime)?
|
||||
.map_err(|e| Error::CallingRuntime(e.into()))?
|
||||
.into_iter()
|
||||
.filter(|id| !local_keys.contains(id.as_ref()))
|
||||
.collect();
|
||||
@@ -546,7 +546,7 @@ where
|
||||
let id = BlockId::hash(client.info().best_hash);
|
||||
let authorities = client.runtime_api()
|
||||
.authorities(&id)
|
||||
.map_err(Error::CallingRuntime)?
|
||||
.map_err(|e| Error::CallingRuntime(e.into()))?
|
||||
.into_iter()
|
||||
.map(std::convert::Into::into)
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
@@ -100,8 +100,6 @@ pub(crate) struct RuntimeApi {
|
||||
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl AuthorityDiscoveryApi<Block> for RuntimeApi {
|
||||
type Error = sp_blockchain::Error;
|
||||
|
||||
fn authorities(&self) -> Vec<AuthorityId> {
|
||||
self.authorities.clone()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user