Skip to main content

SessionInterface

Trait SessionInterface 

Source
pub trait SessionInterface {
    type ValidatorId: Clone;
    type AccountId;
    type Keys: OpaqueKeys + Decode;

    // Required methods
    fn validators() -> Vec<Self::ValidatorId>;
    fn prune_up_to(index: SessionIndex);
    fn report_offence(offender: Self::ValidatorId, severity: OffenceSeverity);
    fn set_keys(account: &Self::AccountId, keys: Self::Keys) -> DispatchResult;
    fn purge_keys(account: &Self::AccountId) -> DispatchResult;
    fn set_keys_weight() -> Weight;
    fn purge_keys_weight() -> Weight;
}
Expand description

Interface to the session pallet for session management.

This trait provides a complete interface for managing sessions from external contexts, such as other pallets or runtime components. It combines session key management with validator operations and historical session data pruning.

Implemented by Pallet<T> when T: Config + historical::Config.

Required Associated Types§

Source

type ValidatorId: Clone

The validator id type of the session pallet.

Source

type AccountId

The account id type.

Source

type Keys: OpaqueKeys + Decode

The session keys type.

Required Methods§

Source

fn validators() -> Vec<Self::ValidatorId>

Get the current set of validators.

Source

fn prune_up_to(index: SessionIndex)

Prune historical session data up to the given session index.

Source

fn report_offence(offender: Self::ValidatorId, severity: OffenceSeverity)

Report an offence for a validator.

This is used to disable validators directly on the RC until the next validator set.

Source

fn set_keys(account: &Self::AccountId, keys: Self::Keys) -> DispatchResult

Set session keys for an account.

This method is intended for privileged callers (e.g., other pallets receiving validated requests via XCM). It bypasses deposit holds and consumer reference tracking, so the account does not need to be “live” or have balance on this chain.

This method does not validate ownership proof. Callers must verify that the keys belong to the account before calling this method.

Source

fn purge_keys(account: &Self::AccountId) -> DispatchResult

Purge session keys for an account.

This method is intended for privileged callers (e.g., other pallets receiving validated requests via XCM). It bypasses deposit release and consumer reference decrement.

Source

fn set_keys_weight() -> Weight

Weight for setting session keys.

Source

fn purge_keys_weight() -> Weight

Weight for purging session keys.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Config + Config> SessionInterface for Pallet<T>

Available on crate feature historical only.