Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix ranked voting math comment #12452

Merged
merged 1 commit into from
Oct 8, 2022
Merged

Conversation

nuke-web3
Copy link
Contributor

Unless I am misunderstanding, the comments are suggesting incorrect values:

/// Vote-weight scheme where all voters get one vote plus an additional vote for every excess rank
/// they have. I.e.:
///
/// - Each member with no excess rank gets 1 vote;
/// - ...with an excess rank of 1 gets 2 votes;
/// - ...with an excess rank of 2 gets 2 votes;
/// - ...with an excess rank of 3 gets 3 votes;
/// - ...with an excess rank of 4 gets 4 votes.
pub struct Linear;
impl Convert<Rank, Votes> for Linear {
fn convert(r: Rank) -> Votes {
(r + 1) as Votes
}
}
/// Vote-weight scheme where all voters get one vote plus additional votes for every excess rank
/// they have incrementing by one vote for each excess rank. I.e.:
///
/// - Each member with no excess rank gets 1 vote;
/// - ...with an excess rank of 1 gets 2 votes;
/// - ...with an excess rank of 2 gets 3 votes;
/// - ...with an excess rank of 3 gets 6 votes;
/// - ...with an excess rank of 4 gets 10 votes.
pub struct Geometric;
impl Convert<Rank, Votes> for Geometric {
fn convert(r: Rank) -> Votes {
let v = (r + 1) as Votes;
v * (v + 1) / 2
}
}

Here is an example:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=eabd12199cf5bcad261dd1986e5c540c

Am I missing something or just a typo in the comments that this PR corrects? 🤞

@nuke-web3 nuke-web3 added A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Oct 8, 2022
@shawntabrizi
Copy link
Member

bot merge

@paritytech-processbot paritytech-processbot bot merged commit b7c0562 into master Oct 8, 2022
@paritytech-processbot paritytech-processbot bot deleted the ds/ranked-vote-math branch October 8, 2022 19:26
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants