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§
Sourcetype ValidatorId: Clone
type ValidatorId: Clone
The validator id type of the session pallet.
Sourcetype Keys: OpaqueKeys + Decode
type Keys: OpaqueKeys + Decode
The session keys type.
Required Methods§
Sourcefn validators() -> Vec<Self::ValidatorId>
fn validators() -> Vec<Self::ValidatorId>
Get the current set of validators.
Sourcefn prune_up_to(index: SessionIndex)
fn prune_up_to(index: SessionIndex)
Prune historical session data up to the given session index.
Sourcefn report_offence(offender: Self::ValidatorId, severity: OffenceSeverity)
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.
Sourcefn set_keys(account: &Self::AccountId, keys: Self::Keys) -> DispatchResult
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.
Sourcefn purge_keys(account: &Self::AccountId) -> DispatchResult
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.
Sourcefn set_keys_weight() -> Weight
fn set_keys_weight() -> Weight
Weight for setting session keys.
Sourcefn purge_keys_weight() -> Weight
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.