Decouple Stkaing and Election - Part1: Support traits (#7908)

* Base features and traits.

* Fix the build

* Remove unused boxing

* Self review cleanup

* Fix build
This commit is contained in:
Kian Paimani
2021-01-18 10:24:12 +00:00
committed by GitHub
parent c58a2d9a74
commit ced107b355
23 changed files with 925 additions and 341 deletions
@@ -23,7 +23,7 @@
use crate::{
IdentifierT, ElectionResult, ExtendedBalance, setup_inputs, VoteWeight, Voter, CandidatePtr,
balance,
balance, PerThing128,
};
use sp_arithmetic::{PerThing, InnerOf, Rational128, traits::Bounded};
use sp_std::{prelude::*, rc::Rc};
@@ -41,13 +41,14 @@ use sp_std::{prelude::*, rc::Rc};
/// assignments, `assignment.distribution.map(|p| p.deconstruct()).sum()` fails to fit inside
/// `UpperOf<P>`. A user of this crate may statically assert that this can never happen and safely
/// `expect` this to return `Ok`.
pub fn phragmms<AccountId: IdentifierT, P: PerThing>(
pub fn phragmms<AccountId: IdentifierT, P: PerThing128>(
to_elect: usize,
initial_candidates: Vec<AccountId>,
initial_voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>,
balancing_config: Option<(usize, ExtendedBalance)>,
) -> Result<ElectionResult<AccountId, P>, &'static str>
where ExtendedBalance: From<InnerOf<P>>
where
ExtendedBalance: From<InnerOf<P>>,
{
let (candidates, mut voters) = setup_inputs(initial_candidates, initial_voters);