mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 04:11:09 +00:00
refactor election score (#10834)
* refactor election score * Test for ord * remove reference * vec -> slice * change iter to iter_by_significance * improve doc * fix typo * add explanation about [u128; 3] * consolidate threshold and epsilon * random fixes * rename * remove Into * make iter_by_sig private * remove vec * Fix tests
This commit is contained in:
@@ -148,7 +148,10 @@ fn solution_with_size<T: Config>(
|
||||
let score = solution.clone().score(stake_of, voter_at, target_at).unwrap();
|
||||
let round = <MultiPhase<T>>::round();
|
||||
|
||||
assert!(score[0] > 0, "score is zero, this probably means that the stakes are not set.");
|
||||
assert!(
|
||||
score.minimal_stake > 0,
|
||||
"score is zero, this probably means that the stakes are not set."
|
||||
);
|
||||
Ok(RawSolution { solution, score, round })
|
||||
}
|
||||
|
||||
@@ -312,7 +315,7 @@ frame_benchmarking::benchmarks! {
|
||||
// the solution will be worse than all of them meaning the score need to be checked against
|
||||
// ~ log2(c)
|
||||
let solution = RawSolution {
|
||||
score: [(10_000_000u128 - 1).into(), 0, 0],
|
||||
score: ElectionScore { minimal_stake: 10_000_000u128 - 1, ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -323,7 +326,7 @@ frame_benchmarking::benchmarks! {
|
||||
let mut signed_submissions = SignedSubmissions::<T>::get();
|
||||
for i in 0..c {
|
||||
let raw_solution = RawSolution {
|
||||
score: [(10_000_000 + i).into(), 0, 0],
|
||||
score: ElectionScore { minimal_stake: 10_000_000u128 + (i as u128), ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
let signed_submission = SignedSubmission {
|
||||
|
||||
Reference in New Issue
Block a user