mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 18:41:03 +00:00
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
This commit is contained in:
committed by
Bastian Köcher
parent
03a3993541
commit
0a3f326e56
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user