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>>;
fn voters(
maybe_max_len: Option<usize>
) -> Result<Vec<(AccountId, VoteWeight, Vec<AccountId>)>>;
fn desired_targets() -> Result<u32>;
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
const MAXIMUM_VOTES_PER_VOTER: u32
const MAXIMUM_VOTES_PER_VOTER: u32
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.
This should be implemented as a self-weighing function. The implementor should register its appropriate weight at the end of execution with the system pallet directly.
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.
This should be implemented as a self-weighing function. The implementor should register its appropriate weight at the end of execution with the system pallet directly.
fn desired_targets() -> Result<u32>
fn desired_targets() -> Result<u32>
The number of targets to elect.
This should be implemented as a self-weighing function. The implementor should register its appropriate weight at the end of execution with the system pallet directly.
fn next_election_prediction(now: BlockNumber) -> BlockNumber
fn next_election_prediction(now: BlockNumber) -> BlockNumber
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
fn put_snapshot(
_voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>,
_targets: Vec<AccountId>,
_target_stake: Option<VoteWeight>
)
fn put_snapshot(
_voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>,
_targets: Vec<AccountId>,
_target_stake: Option<VoteWeight>
)
Utility function only to be used in benchmarking scenarios, to be implemented optionally, else a noop.
fn add_voter(_voter: AccountId, _weight: VoteWeight, _targets: Vec<AccountId>)
fn add_voter(_voter: AccountId, _weight: VoteWeight, _targets: Vec<AccountId>)
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.
fn add_target(_target: AccountId)
fn add_target(_target: AccountId)
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.