referrerpolicy=no-referrer-when-downgrade

SessionInterface

Trait SessionInterface 

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

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

Re-export SessionInterface from pallet_session.

This trait provides the interface to talk to the local session pallet for cross-chain session management. 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§

type ValidatorId: Clone

The validator id type of the session pallet.

type AccountId

The account id type.

type Keys: OpaqueKeys + Decode

The session keys type.

Required Methods§

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

Get the current set of validators.

fn prune_up_to(index: u32)

Prune historical session data up to the given session index.

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.

fn set_keys( account: &Self::AccountId, keys: Self::Keys, ) -> Result<(), DispatchError>

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.

fn purge_keys(account: &Self::AccountId) -> Result<(), DispatchError>

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.

fn set_keys_weight() -> Weight

Weight for setting session keys.

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§

§

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

Available on crate feature historical only.
§

type ValidatorId = <T as Config>::ValidatorId

§

type AccountId = <T as Config>::AccountId

§

type Keys = <T as Config>::Keys