Improve is_member and is_runner. (#4356)

This commit is contained in:
Marcio Diaz
2019-12-11 13:15:27 +01:00
committed by GitHub
parent 6b9c87ef1a
commit 58c1c7a10d
@@ -492,14 +492,14 @@ impl<T: Trait> Module<T> {
///
/// Limited number of members. Binary search. Constant time factor. O(1)
fn is_member(who: &T::AccountId) -> bool {
Self::members_ids().binary_search(who).is_ok()
Self::members().binary_search_by(|(a, _b)| a.cmp(who)).is_ok()
}
/// Check if `who` is currently an active runner.
///
/// Limited number of runners-up. Binary search. Constant time factor. O(1)
fn is_runner(who: &T::AccountId) -> bool {
Self::runners_up_ids().binary_search(who).is_ok()
Self::runners_up().binary_search_by(|(a, _b)| a.cmp(who)).is_ok()
}
/// Returns number of desired members.