mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 08:01:06 +00:00
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:
@@ -19,10 +19,13 @@
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use crate::{seq_phragmen, ElectionResult, Assignment, VoteWeight, ExtendedBalance};
|
||||
use sp_arithmetic::{PerThing, InnerOf, traits::{SaturatedConversion, Zero, One}};
|
||||
use sp_std::collections::btree_map::BTreeMap;
|
||||
use crate::*;
|
||||
use sp_arithmetic::{
|
||||
traits::{One, SaturatedConversion, Zero},
|
||||
InnerOf, PerThing,
|
||||
};
|
||||
use sp_runtime::assert_eq_error_rate;
|
||||
use sp_std::collections::btree_map::BTreeMap;
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub(crate) struct _Candidate<A> {
|
||||
@@ -313,14 +316,13 @@ pub fn check_assignments_sum<T: PerThing>(assignments: Vec<Assignment<AccountId,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn run_and_compare<Output: PerThing>(
|
||||
pub(crate) fn run_and_compare<Output: PerThing128>(
|
||||
candidates: Vec<AccountId>,
|
||||
voters: Vec<(AccountId, Vec<AccountId>)>,
|
||||
stake_of: &Box<dyn Fn(&AccountId) -> VoteWeight>,
|
||||
to_elect: usize,
|
||||
) where
|
||||
ExtendedBalance: From<InnerOf<Output>>,
|
||||
Output: sp_std::ops::Mul<ExtendedBalance, Output = ExtendedBalance>,
|
||||
{
|
||||
// run fixed point code.
|
||||
let ElectionResult { winners, assignments } = seq_phragmen::<_, Output>(
|
||||
|
||||
Reference in New Issue
Block a user