pub trait EstimateNextSessionRotation<BlockNumber> {
    // Required methods
    fn average_session_length() -> BlockNumber;
    fn estimate_current_session_progress(
        now: BlockNumber
    ) -> (Option<Permill>, Weight);
    fn estimate_next_session_rotation(
        now: BlockNumber
    ) -> (Option<BlockNumber>, Weight);
}
Expand description

Something that can estimate at which block the next session rotation will happen (i.e. a new session starts).

The accuracy of the estimates is dependent on the specific implementation, but in order to get the best estimate possible these methods should be called throughout the duration of the session (rather than calling once and storing the result).

This should be the same logical unit that dictates ShouldEndSession to the session module. No assumptions are made about the scheduling of the sessions.

Required Methods§

fn average_session_length() -> BlockNumber

Return the average length of a session.

This may or may not be accurate.

fn estimate_current_session_progress( now: BlockNumber ) -> (Option<Permill>, Weight)

Return an estimate of the current session progress.

None should be returned if the estimation fails to come to an answer.

fn estimate_next_session_rotation( now: BlockNumber ) -> (Option<BlockNumber>, Weight)

Return the block number at which the next session rotation is estimated to happen.

None should be returned if the estimation fails to come to an answer.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<BlockNumber> EstimateNextSessionRotation<BlockNumber> for ()
where BlockNumber: Zero,

§

fn average_session_length() -> BlockNumber

§

fn estimate_current_session_progress( _: BlockNumber ) -> (Option<Permill>, Weight)

§

fn estimate_next_session_rotation( _: BlockNumber ) -> (Option<BlockNumber>, Weight)

§

impl<BlockNumber, Period, Offset> EstimateNextSessionRotation<BlockNumber> for PeriodicSessions<Period, Offset>
where BlockNumber: AtLeast32BitUnsigned + Clone, Period: Get<BlockNumber>, Offset: Get<BlockNumber>,

§

fn average_session_length() -> BlockNumber

§

fn estimate_current_session_progress( now: BlockNumber ) -> (Option<Permill>, Weight)

§

fn estimate_next_session_rotation( now: BlockNumber ) -> (Option<BlockNumber>, Weight)

Implementors§