Check in block authoring that we can author with current authoring version (#4201)

* Check in block authoring that we can author with current authoring version

* Update client/consensus/pow/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Fix compilation
This commit is contained in:
Bastian Köcher
2019-11-29 11:01:11 +01:00
committed by GitHub
parent 0b52f194f5
commit accc678640
18 changed files with 187 additions and 62 deletions
@@ -33,6 +33,9 @@ use codec::Decode;
use sr_primitives::RuntimeString;
pub use sr_primitives::create_runtime_str;
#[cfg(feature = "std")]
use sr_primitives::{traits::Block as BlockT, generic::BlockId};
/// The identity of a particular API interface that the runtime might provide.
pub type ApiId = [u8; 8];
@@ -165,6 +168,27 @@ 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.
fn native_version(&self) -> &NativeVersion;
/// 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()
}
fn runtime_version(&self, at: &BlockId<Block>) -> Result<RuntimeVersion, String> {
(&**self).runtime_version(at)
}
}
#[cfg(feature = "std")]
mod apis_serialize {
use super::*;