Incorporate the new electing/electable naming into the code (#10956)

* Incorporate the new electing/electable naming into the code

* Update frame/election-provider-support/src/lib.rs

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>

* Update frame/election-provider-support/src/lib.rs

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>

* Some additional changes

* fmt

* update codec

* revert lock file to master

* fix doc test

Co-authored-by: Zeke Mostov <z.mostov@gmail.com>
This commit is contained in:
Kian Paimani
2022-03-19 12:24:41 +00:00
committed by GitHub
parent bbfdd38b69
commit 95192f0cda
9 changed files with 81 additions and 69 deletions
@@ -107,12 +107,12 @@
//! fn desired_targets() -> data_provider::Result<u32> {
//! Ok(1)
//! }
//! fn voters(maybe_max_len: Option<usize>)
//! fn electing_voters(maybe_max_len: Option<usize>)
//! -> data_provider::Result<Vec<VoterOf<Self>>>
//! {
//! Ok(Default::default())
//! }
//! fn targets(maybe_max_len: Option<usize>) -> data_provider::Result<Vec<AccountId>> {
//! fn electable_targets(maybe_max_len: Option<usize>) -> data_provider::Result<Vec<AccountId>> {
//! Ok(vec![10, 20, 30])
//! }
//! fn next_election_prediction(now: BlockNumber) -> BlockNumber {
@@ -138,7 +138,7 @@
//! type DataProvider = T::DataProvider;
//!
//! fn elect() -> Result<Supports<AccountId>, Self::Error> {
//! Self::DataProvider::targets(None)
//! Self::DataProvider::electable_targets(None)
//! .map_err(|_| "failed to elect")
//! .map(|t| vec![(t[0], Support::default())])
//! }
@@ -265,16 +265,19 @@ pub trait ElectionDataProvider {
/// Maximum number of votes per voter that this data provider is providing.
type MaxVotesPerVoter: Get<u32>;
/// All possible targets for the election, i.e. the candidates.
/// All possible targets for the election, i.e. the targets that could become elected, thus
/// "electable".
///
/// 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 targets(maybe_max_len: Option<usize>) -> data_provider::Result<Vec<Self::AccountId>>;
fn electable_targets(
maybe_max_len: Option<usize>,
) -> data_provider::Result<Vec<Self::AccountId>>;
/// All possible voters for the election.
/// All the voters that participate in the election, thus "electing".
///
/// Note that if a notion of self-vote exists, it should be represented here.
///
@@ -283,7 +286,7 @@ pub trait ElectionDataProvider {
///
/// 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 voters(maybe_max_len: Option<usize>) -> data_provider::Result<Vec<VoterOf<Self>>>;
fn electing_voters(maybe_max_len: Option<usize>) -> data_provider::Result<Vec<VoterOf<Self>>>;
/// The number of targets to elect.
///