Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
399cf4b
Revamp npos-elections and implement phragmms
kianenigma Jul 19, 2020
6a7354c
Update primitives/npos-elections/src/phragmms.rs
kianenigma Jul 20, 2020
2254e21
Master.into()
kianenigma Jul 27, 2020
bd4c4ca
Merge branch 'kiz-impl-phragmms' of github.com:paritytech/substrate i…
kianenigma Jul 27, 2020
2dcfade
Fix build
kianenigma Jul 27, 2020
b29ff31
Some review grumbles
kianenigma Jul 27, 2020
51e98ff
Master.into()
kianenigma Aug 4, 2020
37b57d8
Add some stuff for remote testing
kianenigma Aug 4, 2020
01e5473
fix some of the grumbles.
kianenigma Aug 4, 2020
3ed7024
Add remote testing stuff.
kianenigma Aug 4, 2020
47640bb
Cleanup
kianenigma Aug 6, 2020
1c765c2
Master.into()
kianenigma Aug 11, 2020
dca91e6
fix docs
kianenigma Aug 11, 2020
2fa2a96
Update primitives/arithmetic/src/rational.rs
kianenigma Aug 12, 2020
3892d26
Master.into()
kianenigma Aug 12, 2020
20e3de0
Small config change
kianenigma Aug 12, 2020
c28858d
Better handling of approval_stake == 0
kianenigma Aug 13, 2020
073325d
Final touhces.
kianenigma Aug 13, 2020
decc17f
Clean fuzzer a bit
kianenigma Aug 13, 2020
c675a20
Clean fuzzer a bit
kianenigma Aug 13, 2020
8f5087b
Merge branch 'master' of github.com:paritytech/substrate into kiz-imp…
kianenigma Aug 13, 2020
b27700d
Master.into()
kianenigma Aug 14, 2020
427ee99
Master.into()
kianenigma Aug 21, 2020
9ec941b
Update primitives/npos-elections/src/balancing.rs
kianenigma Aug 24, 2020
b4a91dd
Master.into()
kianenigma Aug 24, 2020
67d2be6
Fix fuzzer.
kianenigma Sep 11, 2020
432db79
Master.into()
kianenigma Sep 11, 2020
8f75cd9
Better api for normalize
kianenigma Sep 14, 2020
4e10ab9
Master.into()
kianenigma Sep 14, 2020
7a3aa8b
Add noramlize_up
kianenigma Sep 15, 2020
379e4c9
A large number of small fixes.
kianenigma Sep 16, 2020
15f452e
Master.into()
kianenigma Sep 22, 2020
4b26106
make it merge ready
kianenigma Sep 22, 2020
629f39a
Fix warns
kianenigma Sep 23, 2020
06edce5
bump
kianenigma Sep 23, 2020
8fd1959
Fix fuzzers a bit.
kianenigma Sep 23, 2020
c14b64a
Fix warns as well.
kianenigma Sep 23, 2020
9f97731
Fix more tests.
kianenigma Sep 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix build
  • Loading branch information
kianenigma committed Jul 27, 2020
commit 2dcfadee5bd7b854f57d35269a7cae3c5f74b3fe
17 changes: 12 additions & 5 deletions primitives/npos-elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
//!
//! The goal of an election algorithm is to provide an `ElectionResult`. A data composed of:
//! - `winners`: A flat list of identifiers belonging to those who have won the election, usually
//! ordered in some meaningful way.
//! ordered in some meaningful way. They are zipped with their total backing stake.
//! - `assignment`: A mapping from each voter to their winner-only targets, zipped with a ration
//! denoting the amount of support given to that particular target.
//!
//! ```rust
//! # use crate::*;
//! # use sp_npos_elections::*;
//! # use sp_runtime::Perbill;
//! // the winners.
//! let winners = vec![1, 2];
//! let winners = vec![(1, 100), (2, 50)];
//! let assignments = vec![
//! // A voter, giving equal backing to both 1 and 2.
//! Assignment { who: 10, distribution: vec![(1, Perbill::from_percent(50)), (2, Perbill::from_percent(50))] },
Expand All @@ -57,7 +58,7 @@
//! ];
//!
//! // the combination of the two makes the election result.
//! let election_result = ElectionResult { winners, assignment };
//! let election_result = ElectionResult { winners, assignments };
//!
//! ```
//!
Expand Down Expand Up @@ -567,7 +568,9 @@ pub fn is_score_better<P: PerThing>(this: ElectionScore, that: ElectionScore, ep

/// Converts raw inputs to types used in this crate.
///
/// This drops any votes that are pointing to non-candidates.
/// This will perform some cleanup that are most often important:
/// - It drop any votes that are pointing to non-candidates.
/// - Duplicate targets within a voter are also ignored.
pub(crate) fn setup_inputs<AccountId: IdentifierT>(
initial_candidates: Vec<AccountId>,
initial_voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>,
Expand All @@ -587,6 +590,10 @@ pub(crate) fn setup_inputs<AccountId: IdentifierT>(
let voters = initial_voters.into_iter().map(|(who, voter_stake, votes)| {
let mut edges: Vec<Edge<AccountId>> = Vec::with_capacity(votes.len());
for v in votes {
if edges.iter().any(|e| e.who == v) {
// duplicate edge.
continue;
}
if let Some(idx) = c_idx_cache.get(&v) {
// This candidate is valid + already cached.
let mut candidate = candidates[*idx].borrow_mut();
Expand Down