Skip to content
Snippets Groups Projects
Commit 0b0d9d4d authored by Spencer Judge's avatar Spencer Judge Committed by Bastian Köcher
Browse files

Expose some of session module's storage as public, as well as the set_keys transaction (#4175)

* Expose some of session's storage as public, as well as set_keys

Seemingly there's no reason not to do this, as anyone can always do
it the "hard way" by constructing storage keys or extrinsics.

* Use trait to expose `is_registered` function

* Missed removing a pub keyword

* Move trait to support, add docstrings
parent 7d99220d
Branches
Tags
No related merge requests found
......@@ -126,7 +126,7 @@ use support::weights::SimpleDispatchInfo;
use sp_runtime::traits::{Convert, Zero, Member, OpaqueKeys};
use sp_staking::SessionIndex;
use support::{dispatch::Result, ConsensusEngineId, decl_module, decl_event, decl_storage};
use support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor}, Parameter};
use support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor, ValidatorRegistration}, Parameter};
use system::{self, ensure_signed};
#[cfg(test)]
......@@ -333,6 +333,12 @@ impl<V> SelectInitialValidators<V> for () {
}
}
impl<T: Trait> ValidatorRegistration<T::ValidatorId> for Module<T> {
fn is_registered(id: &T::ValidatorId) -> bool {
Self::load_keys(id).is_some()
}
}
pub trait Trait: system::Trait {
/// The overarching event type.
type Event: From<Event> + Into<<Self as system::Trait>::Event>;
......
......@@ -769,3 +769,12 @@ pub trait Randomness<Output> {
Self::random(&[][..])
}
}
/// Implementors of this trait provide information about whether or not some validator has
/// been registered with them. The [Session module](../../pallet_session/index.html) is an implementor.
pub trait ValidatorRegistration<ValidatorId> {
/// Returns true if the provided validator ID has been registered with the implementing runtime
/// module
fn is_registered(id: &ValidatorId) -> bool;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment