Type Alias altair_runtime::Elections
source · pub type Elections = Pallet<Runtime>;
Aliased Type§
struct Elections(/* private fields */);
Implementations
§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
pub fn vote(
origin: <T as Config>::RuntimeOrigin,
votes: Vec<<T as Config>::AccountId>,
value: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn vote( origin: <T as Config>::RuntimeOrigin, votes: Vec<<T as Config>::AccountId>, value: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Vote for a set of candidates for the upcoming round of election. This can be called to set the initial votes, or update already existing votes.
Upon initial voting, value
units of who
’s balance is locked and a deposit amount is
reserved. The deposit is based on the number of votes and can be updated over time.
The votes
should:
- not be empty.
- be less than the number of possible candidates. Note that all current members and runners-up are also automatically candidates for the next round.
If value
is more than who
’s free balance, then the maximum of the two is used.
The dispatch origin of this call must be signed.
§Warning
It is the responsibility of the caller to NOT place all of their balance into the lock and keep some for further operations.
pub fn remove_voter(
origin: <T as Config>::RuntimeOrigin
) -> Result<(), DispatchError>
pub fn remove_voter( origin: <T as Config>::RuntimeOrigin ) -> Result<(), DispatchError>
Remove origin
as a voter.
This removes the lock and returns the deposit.
The dispatch origin of this call must be signed and be a voter.
pub fn submit_candidacy(
origin: <T as Config>::RuntimeOrigin,
candidate_count: u32
) -> Result<(), DispatchError>
pub fn submit_candidacy( origin: <T as Config>::RuntimeOrigin, candidate_count: u32 ) -> Result<(), DispatchError>
Submit oneself for candidacy. A fixed amount of deposit is recorded.
All candidates are wiped at the end of the term. They either become a member/runner-up, or leave the system while their deposit is slashed.
The dispatch origin of this call must be signed.
§Warning
Even if a candidate ends up being a member, they must call [Call::renounce_candidacy
]
to get their deposit back. Losing the spot in an election will always lead to a slash.
The number of current candidates must be provided as witness data.
§Complexity
O(C + log(C)) where C is candidate_count.
pub fn renounce_candidacy(
origin: <T as Config>::RuntimeOrigin,
renouncing: Renouncing
) -> Result<(), DispatchError>
pub fn renounce_candidacy( origin: <T as Config>::RuntimeOrigin, renouncing: Renouncing ) -> Result<(), DispatchError>
Renounce one’s intention to be a candidate for the next election round. 3 potential outcomes exist:
origin
is a candidate and not elected in any set. In this case, the deposit is unreserved, returned and origin is removed as a candidate.origin
is a current runner-up. In this case, the deposit is unreserved, returned and origin is removed as a runner-up.origin
is a current member. In this case, the deposit is unreserved and origin is removed as a member, consequently not being a candidate for the next round anymore. Similar toremove_member
, if replacement runners exists, they are immediately used. If the prime is renouncing, then no prime will exist until the next round.
The dispatch origin of this call must be signed, and have one of the above roles. The type of renouncing must be provided as witness data.
§Complexity
- Renouncing::Candidate(count): O(count + log(count))
- Renouncing::Member: O(1)
- Renouncing::RunnerUp: O(1)
pub fn remove_member(
origin: <T as Config>::RuntimeOrigin,
who: <<T as Config>::Lookup as StaticLookup>::Source,
slash_bond: bool,
rerun_election: bool
) -> Result<(), DispatchError>
pub fn remove_member( origin: <T as Config>::RuntimeOrigin, who: <<T as Config>::Lookup as StaticLookup>::Source, slash_bond: bool, rerun_election: bool ) -> Result<(), DispatchError>
Remove a particular member from the set. This is effective immediately and the bond of the outgoing member is slashed.
If a runner-up is available, then the best runner-up will be removed and replaces the
outgoing member. Otherwise, if rerun_election
is true
, a new phragmen election is
started, else, nothing happens.
If slash_bond
is set to true, the bond of the member being removed is slashed. Else,
it is returned.
The dispatch origin of this call must be root.
Note that this does not affect the designated block number of the next election.
§Complexity
- Check details of remove_and_replace_member() and do_phragmen().
pub fn clean_defunct_voters(
origin: <T as Config>::RuntimeOrigin,
num_voters: u32,
num_defunct: u32
) -> Result<(), DispatchError>
pub fn clean_defunct_voters( origin: <T as Config>::RuntimeOrigin, num_voters: u32, num_defunct: u32 ) -> Result<(), DispatchError>
Clean all voters who are defunct (i.e. they do not serve any purpose at all). The deposit of the removed voters are returned.
This is an root function to be used only for cleaning the state.
The dispatch origin of this call must be root.
§Complexity
- Check is_defunct_voter() details.
§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
pub fn runners_up(
) -> Vec<SeatHolder<<T as Config>::AccountId, <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance>>
pub fn runners_up( ) -> Vec<SeatHolder<<T as Config>::AccountId, <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance>>
An auto-generated getter for [RunnersUp
].
§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
pub fn candidates(
) -> Vec<(<T as Config>::AccountId, <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance)>
pub fn candidates( ) -> Vec<(<T as Config>::AccountId, <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance)>
An auto-generated getter for [Candidates
].
§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
pub fn election_rounds() -> u32
pub fn election_rounds() -> u32
An auto-generated getter for [ElectionRounds
].
Trait Implementations
§impl<T> GetStorageVersion for Pallet<T>where
T: Config,
impl<T> GetStorageVersion for Pallet<T>where
T: Config,
§type CurrentStorageVersion = StorageVersion
type CurrentStorageVersion = StorageVersion
§fn current_storage_version(
) -> <Pallet<T> as GetStorageVersion>::CurrentStorageVersion
fn current_storage_version( ) -> <Pallet<T> as GetStorageVersion>::CurrentStorageVersion
§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
§impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
§impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
§fn module_name() -> &'static str
fn module_name() -> &'static str
§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
§impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
§fn on_initialize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
) -> Weight
fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number ) -> Weight
Hooks::on_initialize
].§impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Hooks::on_runtime_upgrade
].§impl<T> Contains<<T as Config>::AccountId> for Pallet<T>where
T: Config,
impl<T> Contains<<T as Config>::AccountId> for Pallet<T>where
T: Config,
§impl<T> Callable<T> for Pallet<T>where
T: Config,
impl<T> Callable<T> for Pallet<T>where
T: Config,
type RuntimeCall = Call<T>
§impl<T> PalletsInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletsInfoAccess for Pallet<T>where
T: Config,
§impl<T> ContainsLengthBound for Pallet<T>where
T: Config,
impl<T> ContainsLengthBound for Pallet<T>where
T: Config,
§impl<T> OnGenesis for Pallet<T>where
T: Config,
impl<T> OnGenesis for Pallet<T>where
T: Config,
§fn on_genesis()
fn on_genesis()
§impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
§fn on_finalize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
)
fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number )
Hooks::on_finalize
].§impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
fn storage_info() -> Vec<StorageInfo>
§impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
§impl<T> SortedMembers<<T as Config>::AccountId> for Pallet<T>where
T: Config,
impl<T> SortedMembers<<T as Config>::AccountId> for Pallet<T>where
T: Config,
impl<T> Eq for Pallet<T>
§impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
§fn offchain_worker(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
)
fn offchain_worker( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number )
§impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.§impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
§fn on_initialize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
) -> Weight
fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number ) -> Weight
What to do at the end of each block.
Checks if an election needs to happen or not.
§fn integrity_test()
fn integrity_test()
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize
]). Read more§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
§impl<T> IntegrityTest for Pallet<T>where
T: Config,
impl<T> IntegrityTest for Pallet<T>where
T: Config,
§fn integrity_test()
fn integrity_test()
Hooks::integrity_test
].