Fast CompactAssignment search (#8385)

* use more efficient search through candidates in offchain-election

* mark linear accessors as test-only in election-provider-multi-phase

This prevents production code which uses them from compiling.

Also write an efficient helper for getting the target index.

* doc grammar

* use faster target_index_fn in benchmarks

* unbox helper functions

* remove unnecessary import

* write lifetime after primary trait

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Peter Goodspeed-Niklaus
2021-03-18 09:38:58 +01:00
committed by GitHub
parent 15e15e7d8e
commit 05f24931a9
4 changed files with 67 additions and 37 deletions
@@ -145,7 +145,7 @@ impl<T: Config> Pallet<T> {
// closures.
let cache = helpers::generate_voter_cache::<T>(&voters);
let voter_index = helpers::voter_index_fn::<T>(&cache);
let target_index = helpers::target_index_fn_linear::<T>(&targets);
let target_index = helpers::target_index_fn::<T>(&targets);
let voter_at = helpers::voter_at_fn::<T>(&voters);
let target_at = helpers::target_at_fn::<T>(&targets);
let stake_of = helpers::stake_of_fn::<T>(&voters, &cache);