Struct pallet_session::Module
source · [−]pub struct Module<T: Config>(_);
Implementations
sourceimpl<T: Config + 'static> Module<T>
impl<T: Config + 'static> Module<T>
sourcepub fn validators() -> Vec<T::ValidatorId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn validators() -> Vec<T::ValidatorId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
The current set of validators.
sourcepub fn current_index() -> SessionIndex
pub fn current_index() -> SessionIndex
Current index of the session.
sourceimpl<T: Config> Module<T>
impl<T: Config> Module<T>
Can also be called using Call
.
sourcepub fn set_keys(
origin: T::Origin,
keys: T::Keys,
proof: Vec<u8>
) -> DispatchResult
pub fn set_keys(
origin: T::Origin,
keys: T::Keys,
proof: Vec<u8>
) -> DispatchResult
Sets the session key(s) of the function caller to keys
.
Allows an account to set its session key prior to becoming a validator.
This doesn’t take effect until the next session.
The dispatch origin of this function must be signed.
- Complexity:
O(1)
Actual cost depends on the number of length ofT::Keys::key_ids()
which is fixed. - DbReads:
origin account
,T::ValidatorIdOf
,NextKeys
- DbWrites:
origin account
,NextKeys
- DbReads per key id:
KeyOwner
- DbWrites per key id:
KeyOwner
NOTE: Calling this function will bypass origin filters.
sourcepub fn purge_keys(origin: T::Origin) -> DispatchResult
pub fn purge_keys(origin: T::Origin) -> DispatchResult
Removes any session key(s) of the function caller. This doesn’t take effect until the next session.
The dispatch origin of this function must be signed.
- Complexity:
O(1)
in number of key types. Actual cost depends on the number of length ofT::Keys::key_ids()
which is fixed. - DbReads:
T::ValidatorIdOf
,NextKeys
,origin account
- DbWrites:
NextKeys
,origin account
- DbWrites per key id:
KeyOwnder
NOTE: Calling this function will bypass origin filters.
sourceimpl<T: Config> Module<T>
impl<T: Config> Module<T>
sourcepub fn rotate_session()
pub fn rotate_session()
Move on to next session. Register new validator set and session keys. Changes to the validator set have a session of delay to take effect. This allows for equivocation punishment after a fork.
sourcepub fn disable_index(i: usize) -> bool
pub fn disable_index(i: usize) -> bool
Disable the validator of index i
.
Returns true
if this causes a DisabledValidatorsThreshold
of validators
to be already disabled.
sourcepub fn disable(c: &T::ValidatorId) -> Result<bool, ()>
pub fn disable(c: &T::ValidatorId) -> Result<bool, ()>
Disable the validator identified by c
. (If using with the staking module,
this would be their stash account.)
Returns Ok(true)
if more than DisabledValidatorsThreshold
validators in current
session is already disabled.
If used with the staking module it allows to force a new era in such case.
sourcepub fn upgrade_keys<Old, F>(upgrade: F) where
Old: OpaqueKeys + Member + Decode,
F: Fn(T::ValidatorId, Old) -> T::Keys,
pub fn upgrade_keys<Old, F>(upgrade: F) where
Old: OpaqueKeys + Member + Decode,
F: Fn(T::ValidatorId, Old) -> T::Keys,
Upgrade the key type from some old type to a new type. Supports adding and removing key types.
This function should be used with extreme care and only during an
on_runtime_upgrade
block. Misuse of this function can put your blockchain
into an unrecoverable state.
Care should be taken that the raw versions of the
added keys are unique for every ValidatorId, KeyTypeId
combination.
This is an invariant that the session module typically maintains internally.
As the actual values of the keys are typically not known at runtime upgrade,
it’s recommended to initialize the keys to a (unique) dummy value with the expectation
that all validators should invoke set_keys
before those keys are actually
required.
Trait Implementations
sourceimpl<T: Config> EstimateNextNewSession<<T as Config>::BlockNumber> for Module<T>
impl<T: Config> EstimateNextNewSession<<T as Config>::BlockNumber> for Module<T>
sourcefn estimate_next_new_session(now: T::BlockNumber) -> Option<T::BlockNumber>
fn estimate_next_new_session(now: T::BlockNumber) -> Option<T::BlockNumber>
This session module always calls new_session and next_session at the same time, hence we do a simple proxy and pass the function to next rotation.
sourcefn weight(now: T::BlockNumber) -> Weight
fn weight(now: T::BlockNumber) -> Weight
Return the weight of calling estimate_next_new_session
sourceimpl<T: Config> GetPalletVersion for Module<T>
impl<T: Config> GetPalletVersion for Module<T>
sourcefn current_version() -> PalletVersion
fn current_version() -> PalletVersion
Returns the current version of the pallet.
sourcefn storage_version() -> Option<PalletVersion>
fn storage_version() -> Option<PalletVersion>
Returns the version of the pallet that is stored in storage. Read more
sourceimpl<T: Config> IntegrityTest for Module<T>
impl<T: Config> IntegrityTest for Module<T>
sourcefn integrity_test()
fn integrity_test()
Run integrity test. Read more
sourceimpl<T: Config> ModuleErrorMetadata for Module<T>
impl<T: Config> ModuleErrorMetadata for Module<T>
sourceimpl<T: Config + Config> OffchainWorker<<T as Config>::BlockNumber> for Module<T>
impl<T: Config + Config> OffchainWorker<<T as Config>::BlockNumber> for Module<T>
sourcefn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
This function is being called after every block import (when fully synced). Read more
sourceimpl<T: Config + Config> OnFinalize<<T as Config>::BlockNumber> for Module<T>
impl<T: Config + Config> OnFinalize<<T as Config>::BlockNumber> for Module<T>
sourcefn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
The block is being finalized. Implement to have something happen. Read more
sourceimpl<T: Config> OnGenesis for Module<T>
impl<T: Config> OnGenesis for Module<T>
sourcefn on_genesis()
fn on_genesis()
Something that should happen at genesis.
sourceimpl<T: Config + Config> OnInitialize<<T as Config>::BlockNumber> for Module<T>
impl<T: Config + Config> OnInitialize<<T as Config>::BlockNumber> for Module<T>
sourcefn on_initialize(n: T::BlockNumber) -> Weight
fn on_initialize(n: T::BlockNumber) -> Weight
The block is being initialized. Implement to have something happen. Read more
sourceimpl<T: Config> OnRuntimeUpgrade for Module<T>
impl<T: Config> OnRuntimeUpgrade for Module<T>
sourcefn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Perform a module upgrade. Read more
sourceimpl<T: Config> ValidatorRegistration<<T as Config>::ValidatorId> for Module<T>
impl<T: Config> ValidatorRegistration<<T as Config>::ValidatorId> for Module<T>
sourcefn is_registered(id: &T::ValidatorId) -> bool
fn is_registered(id: &T::ValidatorId) -> bool
Returns true if the provided validator ID has been registered with the implementing runtime module Read more
sourceimpl<T: Config> ValidatorSet<<T as Config>::AccountId> for Module<T>
impl<T: Config> ValidatorSet<<T as Config>::AccountId> for Module<T>
type ValidatorId = T::ValidatorId
type ValidatorId = T::ValidatorId
Type for representing validator id in a session.
type ValidatorIdOf = T::ValidatorIdOf
type ValidatorIdOf = T::ValidatorIdOf
A type for converting AccountId
to ValidatorId
.
sourcefn session_index() -> SessionIndex
fn session_index() -> SessionIndex
Returns current session index.
sourcefn validators() -> Vec<Self::ValidatorId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn validators() -> Vec<Self::ValidatorId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns the active set of validators.
impl<T: Copy + Config> Copy for Module<T>
impl<T: Eq + Config> Eq for Module<T>
impl<T: Config> StructuralEq for Module<T>
impl<T: Config> StructuralPartialEq for Module<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Module<T> where
T: RefUnwindSafe,
impl<T> Send for Module<T> where
T: Send,
impl<T> Sync for Module<T> where
T: Sync,
impl<T> Unpin for Module<T> where
T: Unpin,
impl<T> UnwindSafe for Module<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedConversion for T
impl<T> CheckedConversion for T
sourcefn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
Convert from a value of T
into an equivalent instance of Option<Self>
. Read more
sourcefn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
Consume self to return Some
equivalent value of Option<T>
. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
sourcefn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
Convert from a value of T
into an equivalent instance of Self
. Read more
sourcefn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.
sourceimpl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
sourcepub fn unique_saturated_into(self) -> T
pub fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of T
.