Refactor sc_executor::RuntimeInfo trait into 2 parts (#9498)

* Split native executor stuff from wasm executor stuff

* Remove `native_runtime_version` in places

* Fix warning

* Fix test warning

* Remove redundant NativeRuntimeInfo trait

* Add a warning for use_native

* Run cargo fmt

* Revert "Add a warning for use_native"

This reverts commit 9494f765a06037e991dd60524f2ed1b14649bfd6.
This commit is contained in:
Ashley
2021-08-10 15:23:09 +02:00
committed by GitHub
parent b17fa22afc
commit 394c2817d5
14 changed files with 101 additions and 59 deletions
+16 -7
View File
@@ -251,27 +251,36 @@ impl NativeVersion {
}
}
/// Something that can provide the runtime version at a given block and the native runtime version.
#[cfg(feature = "std")]
pub trait GetRuntimeVersion<Block: BlockT> {
/// Returns the version of the native runtime.
pub trait GetNativeVersion {
/// Returns the version of the native runtime.
fn native_version(&self) -> &NativeVersion;
}
/// Something that can provide the runtime version at a given block.
#[cfg(feature = "std")]
pub trait GetRuntimeVersionAt<Block: BlockT> {
/// Returns the version of runtime at the given block.
fn runtime_version(&self, at: &BlockId<Block>) -> Result<RuntimeVersion, String>;
}
#[cfg(feature = "std")]
impl<T: GetRuntimeVersion<Block>, Block: BlockT> GetRuntimeVersion<Block> for std::sync::Arc<T> {
fn native_version(&self) -> &NativeVersion {
(&**self).native_version()
}
impl<T: GetRuntimeVersionAt<Block>, Block: BlockT> GetRuntimeVersionAt<Block>
for std::sync::Arc<T>
{
fn runtime_version(&self, at: &BlockId<Block>) -> Result<RuntimeVersion, String> {
(&**self).runtime_version(at)
}
}
#[cfg(feature = "std")]
impl<T: GetNativeVersion> GetNativeVersion for std::sync::Arc<T> {
fn native_version(&self) -> &NativeVersion {
(&**self).native_version()
}
}
#[cfg(feature = "std")]
mod apis_serialize {
use super::*;