[][src]Trait sp_staking::offence::OnOffenceHandler

pub trait OnOffenceHandler<Reporter, Offender, Res> {
    pub fn on_offence(
        offenders: &[OffenceDetails<Reporter, Offender>],
        slash_fraction: &[Perbill],
        session: SessionIndex
    ) -> Result<Res, ()>;
pub fn can_report() -> bool; }

A trait to take action on an offence.

Used to decouple the module that handles offences and the one that should punish for those offences.

Required methods

pub fn on_offence(
    offenders: &[OffenceDetails<Reporter, Offender>],
    slash_fraction: &[Perbill],
    session: SessionIndex
) -> Result<Res, ()>
[src]

A handler for an offence of a particular kind.

Note that this contains a list of all previous offenders as well. The implementer should cater for a case, where the same authorities were reported for the same offence in the past (see OffenceCount).

The vector of slash_fraction contains Perbills the authorities should be slashed and is computed according to the OffenceCount already. This is of the same length as offenders. Zero is a valid value for a fraction.

The session parameter is the session index of the offence.

The receiver might decide to not accept this offence. In this case, the call site is responsible for queuing the report and re-submitting again.

pub fn can_report() -> bool[src]

Can an offence be reported now or not. This is an method to short-circuit a call into on_offence. Ideally, a correct implementation should return false if on_offence will return Err. Nonetheless, this is up to the implementation and this trait cannot guarantee it.

Loading content...

Implementations on Foreign Types

impl<Reporter, Offender, Res: Default> OnOffenceHandler<Reporter, Offender, Res> for ()[src]

Loading content...

Implementors

Loading content...