pub trait ElectionProvider {
type AccountId;
type BlockNumber;
type Error: Debug;
type DataProvider: ElectionDataProvider<AccountId = Self::AccountId, BlockNumber = Self::BlockNumber>;
fn elect() -> Result<Supports<Self::AccountId>, Self::Error>;
}
Expand description
Something that can compute the result of an election and pass it back to the caller.
This trait only provides an interface to request an election, i.e.
ElectionProvider::elect
. That data required for the election need to be passed to the
implemented of this trait through ElectionProvider::DataProvider
.
Required Associated Types§
sourcetype BlockNumber
type BlockNumber
The block number type.
sourcetype DataProvider: ElectionDataProvider<AccountId = Self::AccountId, BlockNumber = Self::BlockNumber>
type DataProvider: ElectionDataProvider<AccountId = Self::AccountId, BlockNumber = Self::BlockNumber>
The data provider of the election.
Required Methods§
sourcefn elect() -> Result<Supports<Self::AccountId>, Self::Error>
fn elect() -> Result<Supports<Self::AccountId>, Self::Error>
Elect a new set of winners, without specifying any bounds on the amount of data fetched from
Self::DataProvider
. An implementation could nonetheless impose its own custom limits.
The result is returned in a target major format, namely as vector of supports.
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.