Adds check_inherents function to the BlockerBuilder API (#912)

* Adds new `check_inherents` function to the `BlockBuilder` API

* Switch to `check_inherents` in `node-consensus`

* Remove `CheckedBlock`, because it is not required anymore

* Fixes after rebase

* Fixes compilation on stable
This commit is contained in:
Bastian Köcher
2018-10-16 20:30:04 +02:00
committed by Gav Wood
parent 169cf91bb5
commit 8de663f105
12 changed files with 1238 additions and 177 deletions
+15
View File
@@ -22,6 +22,8 @@ extern crate sr_std as rstd;
extern crate sr_primitives as primitives;
#[doc(hidden)]
pub extern crate parity_codec as codec;
#[macro_use]
extern crate parity_codec_derive;
extern crate sr_version as runtime_version;
#[doc(hidden)]
@@ -427,6 +429,17 @@ macro_rules! decl_apis {
};
}
//TODO: Move into runtime!
#[derive(Encode)]
#[cfg_attr(feature = "std", derive(Debug, Decode))]
pub enum BlockBuilderError {
#[cfg(not(feature = "std"))]
Generic(&'static str),
#[cfg(feature = "std")]
Generic(String),
TimestampInFuture(u64),
}
decl_apis! {
/// The `Core` api trait that is mandantory for each runtime.
pub trait Core<Block: BlockT, AuthorityId> {
@@ -468,6 +481,8 @@ decl_apis! {
fn finalise_block() ExtraClientSide(changes: &mut Self::OverlayedChanges) -> <Block as BlockT>::Header;
/// Generate inherent extrinsics.
fn inherent_extrinsics<InherentExtrinsic, UncheckedExtrinsic>(inherent: InherentExtrinsic) -> Vec<UncheckedExtrinsic>;
/// Check that the inherents are valid.
fn check_inherents<InherentData>(block: Block, data: InherentData) -> Result<(), BlockBuilderError>;
/// Generate a random seed.
fn random_seed() -> <Block as BlockT>::Hash;
}