clean the interface of supports map (#9674)

* clean the interface of supports map, make it a bit cleaner and more efficients

* Fix stiff

* fix one test

* Fix warnings
This commit is contained in:
Kian Paimani
2021-09-10 19:39:48 +01:00
committed by GitHub
parent b3092ead23
commit be69e4d2b2
14 changed files with 67 additions and 189 deletions
@@ -24,7 +24,7 @@ use honggfuzz::fuzz;
use rand::{self, SeedableRng};
use sp_npos_elections::{
assignment_ratio_to_staked_normalized, is_score_better, seq_phragmen, to_supports,
to_without_backing, EvaluateSupport, VoteWeight,
EvaluateSupport, VoteWeight,
};
use sp_runtime::Perbill;
@@ -58,8 +58,7 @@ fn main() {
&stake_of,
)
.unwrap();
let winners = to_without_backing(unbalanced.winners.clone());
let score = to_supports(winners.as_ref(), staked.as_ref()).unwrap().evaluate();
let score = to_supports(staked.as_ref()).evaluate();
if score[0] == 0 {
// such cases cannot be improved by balancing.
@@ -83,8 +82,7 @@ fn main() {
&stake_of,
)
.unwrap();
let winners = to_without_backing(balanced.winners);
to_supports(winners.as_ref(), staked.as_ref()).unwrap().evaluate()
to_supports(staked.as_ref()).evaluate()
};
let enhance = is_score_better(balanced_score, unbalanced_score, Perbill::zero());