Adds some derives for the inherent data stuff (#1543)

* Adds some derives for the inherent data stuff

This makes working with them easier.

* More defaults!
This commit is contained in:
Bastian Köcher
2019-01-24 16:09:45 +01:00
committed by GitHub
parent 2c3c4ac0e8
commit e5285e8a8d
2 changed files with 5 additions and 6 deletions
+4 -5
View File
@@ -50,6 +50,7 @@ pub use runtime_primitives::RuntimeString;
pub type InherentIdentifier = [u8; 8];
/// Inherent data to include in a block.
#[derive(Clone, Default)]
pub struct InherentData {
/// All inherent data encoded with parity-codec and an identifier.
data: BTreeMap<InherentIdentifier, Vec<u8>>
@@ -152,7 +153,7 @@ impl codec::Decode for InherentData {
///
/// When a fatal error occurres, all other errors are removed and the implementation needs to
/// abbort checking inherents.
#[derive(Encode, Decode)]
#[derive(Encode, Decode, Clone, Default)]
pub struct CheckInherentsResult {
/// Did the check succeed?
okay: bool,
@@ -243,7 +244,7 @@ impl PartialEq for CheckInherentsResult {
/// All `InherentData` providers.
#[cfg(feature = "std")]
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct InherentDataProviders {
providers: Arc<RwLock<Vec<Box<dyn ProvideInherentData + Send + Sync>>>>,
}
@@ -252,9 +253,7 @@ pub struct InherentDataProviders {
impl InherentDataProviders {
/// Create a new instance.
pub fn new() -> Self {
Self {
providers: Default::default(),
}
Self::default()
}
/// Register an `InherentData` provider.
+1 -1
View File
@@ -71,7 +71,7 @@ use runtime_primitives::ApplyResult;
use runtime_primitives::transaction_validity::TransactionValidity;
use runtime_primitives::generic;
use runtime_primitives::traits::{
Convert, BlakeTwo256, Block as BlockT, DigestFor, NumberFor, Extrinsic, StaticLookup,
Convert, BlakeTwo256, Block as BlockT, DigestFor, NumberFor, StaticLookup,
};
use version::RuntimeVersion;
use council::{motions as council_motions, voting as council_voting};