Rename all the election operations (#6245)

* Rename and move sp-phragmen

* More renames for equalise

* Update main module doc

* Fix line width

* Line width
This commit is contained in:
Kian Paimani
2020-06-05 17:33:13 +02:00
committed by GitHub
parent d63b8e0da0
commit 8a8b4f99c3
35 changed files with 296 additions and 322 deletions
+5 -5
View File
@@ -24,7 +24,7 @@ use frame_benchmarking::{account};
use frame_system::RawOrigin;
use sp_io::hashing::blake2_256;
use rand_chacha::{rand_core::{RngCore, SeedableRng}, ChaChaRng};
use sp_phragmen::*;
use sp_npos_elections::*;
const SEED: u32 = 0;
@@ -138,7 +138,7 @@ pub fn create_validators_with_nominators_for_era<T: Trait>(
/// which has a less score than the seq-phragmen.
pub fn get_weak_solution<T: Trait>(
do_reduce: bool,
) -> (Vec<ValidatorIndex>, CompactAssignments, PhragmenScore, ElectionSize) {
) -> (Vec<ValidatorIndex>, CompactAssignments, ElectionScore, ElectionSize) {
let mut backing_stake_of: BTreeMap<T::AccountId, BalanceOf<T>> = BTreeMap::new();
// self stake
@@ -252,8 +252,8 @@ pub fn get_weak_solution<T: Trait>(
/// worker code.
pub fn get_seq_phragmen_solution<T: Trait>(
do_reduce: bool,
) -> (Vec<ValidatorIndex>, CompactAssignments, PhragmenScore, ElectionSize) {
let sp_phragmen::PhragmenResult {
) -> (Vec<ValidatorIndex>, CompactAssignments, ElectionScore, ElectionSize) {
let sp_npos_elections::ElectionResult {
winners,
assignments,
} = <Module<T>>::do_phragmen::<OffchainAccuracy>().unwrap();
@@ -264,7 +264,7 @@ pub fn get_seq_phragmen_solution<T: Trait>(
/// Returns a solution in which only one winner is elected with just a self vote.
pub fn get_single_winner_solution<T: Trait>(
winner: T::AccountId
) -> Result<(Vec<ValidatorIndex>, CompactAssignments, PhragmenScore, ElectionSize), &'static str> {
) -> Result<(Vec<ValidatorIndex>, CompactAssignments, ElectionScore, ElectionSize), &'static str> {
let snapshot_validators = <Module<T>>::snapshot_validators().unwrap();
let snapshot_nominators = <Module<T>>::snapshot_nominators().unwrap();