mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
Make runtime api generate version and identifier information (#1226)
* Make `decl_runtime_apis!` implement `RuntimeApiInfo` for all runtime apis * Make the runtime side generate the info constants as well * Make `RuntimeApiInfo` implementation use the correct generics * Adds a test for the runtime api info stuff * Remove duplicated code by using block from `test-client` * Adds `compile_fail` tests for `api_version` * Adds documentation for `api_version` * Make `impl_runtime_apis!` generate `RUNTIME_API_VERSIONS` * Update documentation and tests for `RUNTIME_API_VERSIONS` * Implement `has_api` by using the `RuntimeApiInfo` * Make `impl_runtime_apis` check that trait identifiers are unique * Prefix all runtime api function with the corresponding trait So `execute_block` will be called `Core_execute_block`. This makes it possible to have traits implement a function with the same name. * Rebase master * Update after master rebase
This commit is contained in:
@@ -24,14 +24,14 @@ use parking_lot::Mutex;
|
||||
use tokio::runtime::current_thread;
|
||||
use keyring::Keyring;
|
||||
use client::{
|
||||
BlockchainEvents, runtime_api::{Core, RuntimeVersion, ApiExt, ConstructRuntimeApi, CallApiAt},
|
||||
error::Result
|
||||
BlockchainEvents, error::Result,
|
||||
runtime_api::{Core, RuntimeVersion, ApiExt, ConstructRuntimeApi, CallRuntimeAt},
|
||||
};
|
||||
use test_client::{self, runtime::BlockNumber};
|
||||
use codec::Decode;
|
||||
use consensus_common::BlockOrigin;
|
||||
use std::{collections::HashSet, result};
|
||||
use runtime_primitives::traits::{ApiRef, ProvideRuntimeApi};
|
||||
use runtime_primitives::traits::{ApiRef, ProvideRuntimeApi, RuntimeApiInfo};
|
||||
use runtime_primitives::generic::BlockId;
|
||||
|
||||
use authorities::AuthoritySet;
|
||||
@@ -277,17 +277,21 @@ impl Core<Block> for RuntimeApi {
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiExt for RuntimeApi {
|
||||
impl ApiExt<Block> for RuntimeApi {
|
||||
fn map_api_result<F: FnOnce(&Self) -> result::Result<R, E>, R, E>(
|
||||
&self,
|
||||
_: F
|
||||
) -> result::Result<R, E> {
|
||||
unimplemented!("Not required for testing!")
|
||||
}
|
||||
|
||||
fn has_api<A: RuntimeApiInfo + ?Sized>(&self, _: &BlockId<Block>) -> Result<bool> {
|
||||
unimplemented!("Not required for testing!")
|
||||
}
|
||||
}
|
||||
|
||||
impl ConstructRuntimeApi<Block> for RuntimeApi {
|
||||
fn construct_runtime_api<'a, T: CallApiAt<Block>>(_: &'a T) -> ApiRef<'a, Self> {
|
||||
fn construct_runtime_api<'a, T: CallRuntimeAt<Block>>(_: &'a T) -> ApiRef<'a, Self> {
|
||||
unimplemented!("Not required for testing!")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user