[][src]Function sp_phragmen::elect

pub fn elect<AccountId, Balance, FS, C, R>(
    candidate_count: usize,
    minimum_candidate_count: usize,
    initial_candidates: Vec<AccountId>,
    initial_voters: Vec<(AccountId, Vec<AccountId>)>,
    stake_of: FS
) -> Option<PhragmenResult<AccountId, R>> where
    AccountId: Default + Ord + Member,
    Balance: Default + Copy + AtLeast32Bit,
    FS: Fn(&'r AccountId) -> Balance,
    C: Convert<Balance, u64> + Convert<u128, Balance>,
    R: PerThing, 

Perform election based on Phragmén algorithm.

Returns an Option the set of winners and their detailed support ratio from each voter if enough candidates are provided. Returns None otherwise.

  • candidate_count: number of candidates to elect.
  • minimum_candidate_count: minimum number of candidates to elect. If less candidates exist, None is returned.
  • initial_candidates: candidates list to be elected from.
  • initial_voters: voters list.
  • stake_of: something that can return the stake stake of a particular candidate or voter.

This function does not strip out candidates who do not have any backing stake. It is the responsibility of the caller to make sure only those candidates who have a sensible economic value are passed in. From the perspective of this function, a candidate can easily be among the winner with no backing stake.