Trait frame_election_provider_support::ElectionDataProvider[][src]

pub trait ElectionDataProvider<AccountId, BlockNumber> {
    const MAXIMUM_VOTES_PER_VOTER: u32;

    fn targets(maybe_max_len: Option<usize>) -> Result<(Vec<AccountId>, Weight)>;
fn voters(
        maybe_max_len: Option<usize>
    ) -> Result<(Vec<(AccountId, VoteWeight, Vec<AccountId>)>, Weight)>;
fn desired_targets() -> Result<(u32, Weight)>;
fn next_election_prediction(now: BlockNumber) -> BlockNumber; fn put_snapshot(
        _voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>,
        _targets: Vec<AccountId>,
        _target_stake: Option<VoteWeight>
    ) { ... }
fn add_voter(
        _voter: AccountId,
        _weight: VoteWeight,
        _targets: Vec<AccountId>
    ) { ... }
fn add_target(_target: AccountId) { ... }
fn clear() { ... } }
Expand description

Something that can provide the data to an ElectionProvider.

Associated Constants

Maximum number of votes per voter that this data provider is providing.

Required methods

All possible targets for the election, i.e. the candidates.

If maybe_max_len is Some(v) then the resulting vector MUST NOT be longer than v items long.

It is assumed that this function will only consume a notable amount of weight, when it returns Ok(_).

All possible voters for the election.

Note that if a notion of self-vote exists, it should be represented here.

If maybe_max_len is Some(v) then the resulting vector MUST NOT be longer than v items long.

It is assumed that this function will only consume a notable amount of weight, when it returns Ok(_).

The number of targets to elect.

Provide a best effort prediction about when the next election is about to happen.

In essence, the implementor should predict with this function when it will trigger the ElectionProvider::elect.

This is only useful for stateful election providers.

Provided methods

Utility function only to be used in benchmarking scenarios, to be implemented optionally, else a noop.

Utility function only to be used in benchmarking scenarios, to be implemented optionally, else a noop.

Same as put_snapshot, but can add a single voter one by one.

Utility function only to be used in benchmarking scenarios, to be implemented optionally, else a noop.

Same as put_snapshot, but can add a single voter one by one.

Clear all voters and targets.

Implementations on Foreign Types

Implementors