referrerpolicy=no-referrer-when-downgrade
pallet_conviction_voting

Type Alias TallyOf

Source
pub type TallyOf<T, I = ()> = Tally<BalanceOf<T, I>, <T as Config<I>>::MaxTurnout>;

Aliased Type§

struct TallyOf<T, I = ()> {
    pub ayes: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance,
    pub nays: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance,
    pub support: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance,
    /* private fields */
}

Fields§

§ayes: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance

The number of aye votes, expressed in terms of post-conviction lock-vote.

§nays: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance

The number of nay votes, expressed in terms of post-conviction lock-vote.

§support: <<T as Config<I>>::Currency as Currency<<T as Config>::AccountId>>::Balance

The basic number of aye votes, expressed pre-conviction.

Implementations

Source§

impl<Votes: Clone + Default + PartialEq + Eq + Debug + Copy + AtLeast32BitUnsigned + TypeInfo + Codec, Total: Get<Votes>> Tally<Votes, Total>

Source

pub fn from_vote(vote: Vote, balance: Votes) -> Self

Create a new tally.

Source

pub fn from_parts( ayes_with_conviction: Votes, nays_with_conviction: Votes, support: Votes, ) -> Self

Source

pub fn add(&mut self, vote: AccountVote<Votes>) -> Option<()>

Add an account’s vote into the tally.

Source

pub fn remove(&mut self, vote: AccountVote<Votes>) -> Option<()>

Remove an account’s vote from the tally.

Source

pub fn increase(&mut self, approve: bool, delegations: Delegations<Votes>)

Increment some amount of votes.

Source

pub fn reduce(&mut self, approve: bool, delegations: Delegations<Votes>)

Decrement some amount of votes.

Trait Implementations

Source§

impl<Votes: Clone + PartialEq + Eq + Debug + TypeInfo + Codec, Total> Clone for Tally<Votes, Total>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Votes: Clone + PartialEq + Eq + Debug + TypeInfo + Codec, Total> Debug for Tally<Votes, Total>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Votes, Total> Decode for Tally<Votes, Total>
where Votes: Decode + Clone + PartialEq + Eq + Debug + TypeInfo + Codec, PhantomData<Total>: Decode,

Source§

fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
Source§

impl<Votes, Total> Encode for Tally<Votes, Total>
where Votes: Encode + Clone + PartialEq + Eq + Debug + TypeInfo + Codec, PhantomData<Total>: Encode,

Source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
Source§

fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
Source§

impl<Votes, Total> MaxEncodedLen for Tally<Votes, Total>
where Votes: MaxEncodedLen + Clone + PartialEq + Eq + Debug + TypeInfo + Codec,

Source§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
Source§

impl<Votes: Clone + PartialEq + Eq + Debug + TypeInfo + Codec, Total> PartialEq for Tally<Votes, Total>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Votes, Total> TypeInfo for Tally<Votes, Total>
where Votes: TypeInfo + 'static + Clone + PartialEq + Eq + Debug + TypeInfo + Codec, PhantomData<Total>: TypeInfo + 'static, Total: 'static,

Source§

type Identity = Tally<Votes, Total>

The type identifying for which type info is provided. Read more
Source§

fn type_info() -> Type

Returns the static type identifier for Self.
Source§

impl<Votes: Clone + Default + PartialEq + Eq + Debug + Copy + AtLeast32BitUnsigned + TypeInfo + Codec, Total: Get<Votes>, Class> VoteTally<Votes, Class> for Tally<Votes, Total>

Source§

fn new(_: Class) -> Self

Initializes a new tally.
Source§

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

Returns the number of positive votes for the tally.
Source§

fn support(&self, _: 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) -> Perbill

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

fn unanimity(_: Class) -> Self

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

fn rejection(_: Class) -> Self

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

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

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

fn setup(_: Class, _: Perbill)

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

impl<Votes, Total> DecodeWithMemTracking for Tally<Votes, Total>
where Votes: DecodeWithMemTracking + Clone + PartialEq + Eq + Debug + TypeInfo + Codec, PhantomData<Total>: DecodeWithMemTracking,

Source§

impl<Votes, Total> EncodeLike for Tally<Votes, Total>
where Votes: Encode + Clone + PartialEq + Eq + Debug + TypeInfo + Codec, PhantomData<Total>: Encode,

Source§

impl<Votes: Clone + PartialEq + Eq + Debug + TypeInfo + Codec, Total> Eq for Tally<Votes, Total>