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§

source

type Key: Decode + RuntimeAppPublic

The key type expected.

Required Methods§

source

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.

source

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.

source

fn on_disabled(_validator_index: u32)

A validator got disabled. Act accordingly until a new session begins.

Provided Methods§

source

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.

Object Safety§

This trait is not object safe.

Implementors§