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,

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>

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>

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>

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 to remove_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>

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>

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,

pub fn members( ) -> Vec<SeatHolder<<T as Config>::AccountId, <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance>>

An auto-generated getter for [Members].

§

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>>

An auto-generated getter for [RunnersUp].

§

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)>

An auto-generated getter for [Candidates].

§

impl<T> Pallet<T>
where T: Config,

pub fn election_rounds() -> u32

An auto-generated getter for [ElectionRounds].

§

impl<T> Pallet<T>
where T: Config,

pub fn voting<KArg>( k: KArg ) -> Voter<<T as Config>::AccountId, <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance>
where KArg: EncodeLike<<T as Config>::AccountId>,

An auto-generated getter for [Voting].

Trait Implementations

§

impl<T> GetStorageVersion for Pallet<T>
where T: Config,

§

type CurrentStorageVersion = StorageVersion

This will be filled out by the pallet macro. Read more
§

fn current_storage_version( ) -> <Pallet<T> as GetStorageVersion>::CurrentStorageVersion

Returns the current storage version as supported by the pallet.
§

fn on_chain_storage_version() -> StorageVersion

Returns the on-chain storage version of the pallet as stored in the storage.
§

impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

§

fn on_idle( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, remaining_weight: Weight ) -> Weight

See [Hooks::on_idle].
§

impl<T> PalletInfoAccess for Pallet<T>
where T: Config,

§

fn index() -> usize

Index of the pallet as configured in the runtime.
§

fn name() -> &'static str

Name of the pallet as configured in the runtime.
§

fn name_hash() -> [u8; 16]

Two128 hash of name.
§

fn module_name() -> &'static str

Name of the Rust module containing the pallet.
§

fn crate_version() -> CrateVersion

Version of the crate containing the pallet.
§

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

See [Hooks::on_initialize].
§

impl<T> Debug for Pallet<T>

§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> OnRuntimeUpgrade for Pallet<T>
where T: Config,

§

fn on_runtime_upgrade() -> Weight

See [Hooks::on_runtime_upgrade].
§

impl<T> Contains<<T as Config>::AccountId> for Pallet<T>
where T: Config,

§

fn contains(who: &<T as Config>::AccountId) -> bool

Return true if this “contains” the given value t.
§

impl<T> Callable<T> for Pallet<T>
where T: Config,

§

type RuntimeCall = Call<T>

§

impl<T> PalletsInfoAccess for Pallet<T>
where T: Config,

§

fn count() -> usize

The number of pallets’ information that this type represents. Read more
§

fn infos() -> Vec<PalletInfoData>

All of the pallets’ information that this type represents.
§

impl<T> ContainsLengthBound for Pallet<T>
where T: Config,

§

fn max_len() -> usize

Implementation uses a parameter type so calling is cost-free.

§

fn min_len() -> usize

Minimum number of elements contained
§

impl<T> OnGenesis for Pallet<T>
where T: Config,

§

fn on_genesis()

Something that should happen at genesis.
§

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 )

See [Hooks::on_finalize].
§

impl<T> StorageInfoTrait for Pallet<T>
where T: Config,

§

fn storage_info() -> Vec<StorageInfo>

§

impl<T> BeforeAllRuntimeMigrations for Pallet<T>
where T: Config,

§

fn before_all_runtime_migrations() -> Weight

Something that should happen before runtime migrations are executed.
§

impl<T> SortedMembers<<T as Config>::AccountId> for Pallet<T>
where T: Config,

§

fn contains(who: &<T as Config>::AccountId) -> bool

Return true if this “contains” the given value t.
§

fn sorted_members() -> Vec<<T as Config>::AccountId>

Get a vector of all members in the set, ordered.
§

fn count() -> usize

Get the number of items in the set.
§

impl<T> PartialEq for Pallet<T>

§

fn eq(&self, other: &Pallet<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

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,

§

fn offchain_worker( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number )

This function is being called after every block import (when fully synced). Read more
§

impl<T> WhitelistedStorageKeys for Pallet<T>
where T: Config,

§

fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>

Returns a 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,

§

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()

Check the integrity of this pallet’s configuration. Read more
§

fn on_finalize(_n: BlockNumber)

Block finalization hook. This is called at the very end of block execution. Read more
§

fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight

Hook to consume a block’s idle time. This will run when the block is being finalized (before [Hooks::on_finalize]). Read more
§

fn on_runtime_upgrade() -> Weight

Hook executed when a code change (aka. a “runtime upgrade”) is detected by FRAME. Read more
§

fn offchain_worker(_n: BlockNumber)

Implementing this function on a pallet allows you to perform long-running tasks that are dispatched as separate threads, and entirely independent of the main wasm runtime. Read more
§

impl<T> Clone for Pallet<T>

§

fn clone(&self) -> Pallet<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> IntegrityTest for Pallet<T>
where T: Config,

§

fn integrity_test()

See [Hooks::integrity_test].