Skip to content
Snippets Groups Projects
Unverified Commit 8a8f6f98 authored by Pablo Andrés Dorado Suárez's avatar Pablo Andrés Dorado Suárez Committed by GitHub
Browse files

[Documentation] Add description for VoteTally's methods (#3140)


# Description

While methods' names on [`VoteTally`][1] trait might be self-explanatory
at first sight, the distinction between `support` and `approval` can be
a bit ambiguous for some readers. This PR aims to clarify the
distinction and inform about the expected values for every not yet
documented method on this trait.

# Checklist

- [x] My PR includes a detailed description as outlined in the
"Description" section above
- [ ] My PR follows the [labeling requirements](CONTRIBUTING.md#Process)
of this project (at minimum one label for `T`
  required)
- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works (if applicable)

[1]:
https://docs.rs/frame-support/latest/frame_support/traits/trait.VoteTally.html

---------

Co-authored-by: default avatarBastian Köcher <git@kchr.de>
parent 07e55006
No related merge requests found
Pipeline #440152 passed with stages
in 47 minutes and 30 seconds
......@@ -25,14 +25,24 @@ use sp_runtime::{traits::Member, DispatchError};
use sp_std::prelude::*;
pub trait VoteTally<Votes, Class> {
/// Initializes a new tally.
fn new(_: Class) -> Self;
/// Returns the number of positive votes for the tally.
fn ayes(&self, class: Class) -> Votes;
/// Returns the approval ratio (positive to total votes) for the tally, without multipliers
/// (e.g. conviction, ranks, etc.).
fn support(&self, class: Class) -> Perbill;
/// Returns the approval ratio (positive to total votes) for the tally.
fn approval(&self, class: Class) -> Perbill;
/// Returns an instance of the tally representing a unanimous approval, for benchmarking
/// purposes.
#[cfg(feature = "runtime-benchmarks")]
fn unanimity(class: Class) -> Self;
/// Returns an instance of the tally representing a rejecting state, for benchmarking purposes.
#[cfg(feature = "runtime-benchmarks")]
fn rejection(class: Class) -> Self;
/// Returns an instance of the tally given some `approval` and `support`, for benchmarking
/// purposes.
#[cfg(feature = "runtime-benchmarks")]
fn from_requirements(support: Perbill, approval: Perbill, class: Class) -> Self;
#[cfg(feature = "runtime-benchmarks")]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment