referrerpolicy=no-referrer-when-downgrade

Trait polkadot_sdk_frame::traits::Polling

pub trait Polling<Tally> {
    type Index: Parameter + Member + Ord + PartialOrd + Copy + HasCompact + MaxEncodedLen;
    type Votes: Parameter + Member + Ord + PartialOrd + Copy + HasCompact + MaxEncodedLen;
    type Class: Parameter + Member + Ord + PartialOrd + MaxEncodedLen;
    type Moment;

    // Required methods
    fn classes() -> Vec<Self::Class>;
    fn as_ongoing(index: Self::Index) -> Option<(Tally, Self::Class)>;
    fn access_poll<R>(
        index: Self::Index,
        f: impl FnOnce(PollStatus<&mut Tally, Self::Moment, Self::Class>) -> R,
    ) -> R;
    fn try_access_poll<R>(
        index: Self::Index,
        f: impl FnOnce(PollStatus<&mut Tally, Self::Moment, Self::Class>) -> Result<R, DispatchError>,
    ) -> Result<R, DispatchError>;
    fn create_ongoing(class: Self::Class) -> Result<Self::Index, ()>;
    fn end_ongoing(index: Self::Index, approved: bool) -> Result<(), ()>;

    // Provided method
    fn max_ongoing() -> (Self::Class, u32) { ... }
}

Required Associated Types§

type Index: Parameter + Member + Ord + PartialOrd + Copy + HasCompact + MaxEncodedLen

type Votes: Parameter + Member + Ord + PartialOrd + Copy + HasCompact + MaxEncodedLen

type Class: Parameter + Member + Ord + PartialOrd + MaxEncodedLen

type Moment

Required Methods§

fn classes() -> Vec<Self::Class>

Provides a vec of values that T may take.

fn as_ongoing(index: Self::Index) -> Option<(Tally, Self::Class)>

Some if the referendum index can be voted on, along with the tally and class of referendum.

Don’t use this if you might mutate - use try_access_poll instead.

fn access_poll<R>( index: Self::Index, f: impl FnOnce(PollStatus<&mut Tally, Self::Moment, Self::Class>) -> R, ) -> R

fn try_access_poll<R>( index: Self::Index, f: impl FnOnce(PollStatus<&mut Tally, Self::Moment, Self::Class>) -> Result<R, DispatchError>, ) -> Result<R, DispatchError>

fn create_ongoing(class: Self::Class) -> Result<Self::Index, ()>

Create an ongoing majority-carries poll of given class lasting given period for the purpose of benchmarking.

May return Err if it is impossible.

fn end_ongoing(index: Self::Index, approved: bool) -> Result<(), ()>

End the given ongoing poll and return the result.

Returns Err if index is not an ongoing poll.

Provided Methods§

fn max_ongoing() -> (Self::Class, u32)

The maximum amount of ongoing polls within any single class. By default it practically unlimited (u32::max_value()).

Object Safety§

This trait is not object safe.

Implementors§

§

impl<Tally> Polling<Tally> for NoOpPoll

§

type Index = u8

§

type Votes = u32

§

type Class = u16

§

type Moment = u64