referrerpolicy=no-referrer-when-downgrade
frame_support::traits

Trait VoteTally

Source
pub trait VoteTally<Votes, Class> {
    // Required methods
    fn new(_: Class) -> Self;
    fn ayes(&self, class: Class) -> Votes;
    fn support(&self, class: Class) -> Perbill;
    fn approval(&self, class: Class) -> Perbill;
    fn unanimity(class: Class) -> Self;
    fn rejection(class: Class) -> Self;
    fn from_requirements(
        support: Perbill,
        approval: Perbill,
        class: Class,
    ) -> Self;
    fn setup(class: Class, granularity: Perbill);
}

Required Methods§

Source

fn new(_: Class) -> Self

Initializes a new tally.

Source

fn ayes(&self, class: Class) -> Votes

Returns the number of positive votes for the tally.

Source

fn support(&self, class: Class) -> Perbill

Returns the approval ratio (positive to total votes) for the tally, without multipliers (e.g. conviction, ranks, etc.).

Source

fn approval(&self, class: Class) -> Perbill

Returns the approval ratio (positive to total votes) for the tally.

Source

fn unanimity(class: Class) -> Self

Returns an instance of the tally representing a unanimous approval, for benchmarking purposes.

Source

fn rejection(class: Class) -> Self

Returns an instance of the tally representing a rejecting state, for benchmarking purposes.

Source

fn from_requirements(support: Perbill, approval: Perbill, class: Class) -> Self

Returns an instance of the tally given some approval and support, for benchmarking purposes.

Source

fn setup(class: Class, granularity: Perbill)

A function that should be called before any use of the runtime-benchmarks gated functions of the VoteTally trait.

Should be used to set up any needed state in a Pallet which implements VoteTally so that benchmarks that execute will complete successfully. class can be used to set up a particular class of voters, and granularity is used to determine the weight of one vote relative to total unanimity.

For example, in the case where there are a number of unique voters, and each voter has equal voting weight, a granularity of Perbill::from_rational(1, 1000) should create 1_000 users.

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<Votes: Clone + Default + PartialEq + Eq + Debug + Copy + AtLeast32BitUnsigned + TypeInfo + Codec, Total: Get<Votes>, Class> VoteTally<Votes, Class> for Tally<Votes, Total>

impl<T: Config<I>, I: 'static, M: GetMaxVoters<Class = ClassOf<T, I>>> VoteTally<u32, <<T as Config<I>>::Polls as Polling<Tally<T, I, Pallet<T, I>>>>::Class> for Tally<T, I, M>