From e5285e8a8dceb94df35dfa5065e8b89567105c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 24 Jan 2019 16:09:45 +0100 Subject: [PATCH] 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! --- substrate/core/inherents/src/lib.rs | 9 ++++----- substrate/node/runtime/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/substrate/core/inherents/src/lib.rs b/substrate/core/inherents/src/lib.rs index 16910fd4ab..9bf9272e57 100644 --- a/substrate/core/inherents/src/lib.rs +++ b/substrate/core/inherents/src/lib.rs @@ -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> @@ -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>>>, } @@ -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. diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index d7599c2c7f..f25a46f267 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -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};