Trait frame_support::traits::OneSessionHandler
source · pub trait OneSessionHandler<ValidatorId>: BoundToRuntimeAppPublic {
type Key: Decode + RuntimeAppPublic;
// Required methods
fn on_genesis_session<'a, I>(validators: I)
where I: Iterator<Item = (&'a ValidatorId, Self::Key)> + 'a,
ValidatorId: 'a;
fn on_new_session<'a, I>(changed: bool, validators: I, queued_validators: I)
where I: Iterator<Item = (&'a ValidatorId, Self::Key)> + 'a,
ValidatorId: 'a;
fn on_disabled(_validator_index: u32);
// Provided method
fn on_before_session_ending() { ... }
}
Expand description
A session handler for specific key type.
Required Associated Types§
sourcetype Key: Decode + RuntimeAppPublic
type Key: Decode + RuntimeAppPublic
The key type expected.
Required Methods§
sourcefn on_genesis_session<'a, I>(validators: I)where
I: Iterator<Item = (&'a ValidatorId, Self::Key)> + 'a,
ValidatorId: 'a,
fn on_genesis_session<'a, I>(validators: I)where I: Iterator<Item = (&'a ValidatorId, Self::Key)> + 'a, ValidatorId: 'a,
The given validator set will be used for the genesis session.
It is guaranteed that the given validator set will also be used
for the second session, therefore the first call to on_new_session
should provide the same validator set.
sourcefn on_new_session<'a, I>(changed: bool, validators: I, queued_validators: I)where
I: Iterator<Item = (&'a ValidatorId, Self::Key)> + 'a,
ValidatorId: 'a,
fn on_new_session<'a, I>(changed: bool, validators: I, queued_validators: I)where I: Iterator<Item = (&'a ValidatorId, Self::Key)> + 'a, ValidatorId: 'a,
Session set has changed; act appropriately. Note that this can be called before initialization of your module.
changed
is true when at least one of the session keys
or the underlying economic identities/distribution behind one the
session keys has changed, false otherwise.
The validators
are the validators of the incoming session, and queued_validators
will follow.
sourcefn on_disabled(_validator_index: u32)
fn on_disabled(_validator_index: u32)
A validator got disabled. Act accordingly until a new session begins.
Provided Methods§
sourcefn on_before_session_ending()
fn on_before_session_ending()
A notification for end of the session.
Note it is triggered before any SessionManager::end_session
handlers,
so we can still affect the validator set.