From 91b44299d8bb97137b2d1a1973e1edf6f303c170 Mon Sep 17 00:00:00 2001 From: Gavin Wood <gavin@parity.io> Date: Thu, 5 Mar 2020 13:37:59 +0100 Subject: [PATCH] Adds a session getter to historical proofs (#5125) * Adds a session getter to historical proofs * Bump spec_version * Adds some useful trait derives to Proof --- substrate/bin/node/runtime/src/lib.rs | 2 +- substrate/frame/session/src/historical.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 0844b32f7c3..1cc0a2b7251 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -82,7 +82,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 229, + spec_version: 230, impl_version: 0, apis: RUNTIME_API_VERSIONS, }; diff --git a/substrate/frame/session/src/historical.rs b/substrate/frame/session/src/historical.rs index 5b492d8d21d..91719c27f27 100644 --- a/substrate/frame/session/src/historical.rs +++ b/substrate/frame/session/src/historical.rs @@ -27,7 +27,7 @@ use sp_std::prelude::*; use codec::{Encode, Decode}; -use sp_runtime::KeyTypeId; +use sp_runtime::{KeyTypeId, RuntimeDebug}; use sp_runtime::traits::{Convert, OpaqueKeys}; use frame_support::{decl_module, decl_storage}; use frame_support::{Parameter, print}; @@ -258,12 +258,19 @@ impl<T: Trait> ProvingTrie<T> { } /// Proof of ownership of a specific key. -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug)] pub struct Proof { session: SessionIndex, trie_nodes: Vec<Vec<u8>>, } +impl Proof { + /// Returns a session this proof was generated for. + pub fn session(&self) -> SessionIndex { + self.session + } +} + impl<T: Trait, D: AsRef<[u8]>> frame_support::traits::KeyOwnerProofSystem<(KeyTypeId, D)> for Module<T> { -- GitLab