* rename Event to RuntimeEvent * rename Call * rename in runtimes * small fix * rename Event * small fix & rename RuntimeCall back to Call for now * small fixes * more renaming * a bit more renaming * fmt * small fix * commit * prep for renaming associated types * fix * rename associated Event type * rename to RuntimeEvent * commit * merge conflict fixes & fmt * additional renaming * fix. * fix decl_event * rename in tests * remove warnings * remove accidental rename * . * commit * update .stderr * fix in test * update .stderr * TRYBUILD=overwrite * docs * fmt * small change in docs * rename PalletEvent to Event * rename Call to RuntimeCall * renamed at wrong places :P * rename Call * rename * rename associated type * fix * fix & fmt * commit * frame-support-test * passing tests * update docs * rustdoc fix * update .stderr * wrong code in docs * merge fix * fix in error message * update .stderr * docs & error message * . * merge fix * merge fix * fmt * fmt * merge fix * more fixing * fmt * remove unused * fmt * fix Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Scored Pool Module
The module maintains a scored membership pool. Each entity in the
pool can be attributed a Score. From this pool a set Members
is constructed. This set contains the MemberCount highest
scoring entities. Unscored entities are never part of Members.
If an entity wants to be part of the pool a deposit is required. The deposit is returned when the entity withdraws or when it is removed by an entity with the appropriate authority.
Every Period blocks the set of Members is refreshed from the
highest scoring members in the pool and, no matter if changes
occurred, T::MembershipChanged::set_members_sorted is invoked.
On first load T::MembershipInitialized::initialize_members is
invoked with the initial Members set.
It is possible to withdraw candidacy/resign your membership at any
time. If an entity is currently a member, this results in removal
from the Pool and Members; the entity is immediately replaced
by the next highest scoring candidate in the pool, if available.
Interface
Public Functions
submit_candidacy- Submit candidacy to become a member. Requires a deposit.withdraw_candidacy- Withdraw candidacy. Deposit is returned.score- Attribute a quantitative score to an entity.kick- Remove an entity from the pool and members. Deposit is returned.change_member_count- Changes the amount of candidates taken intoMembers.
Usage
use pallet_scored_pool::{self as scored_pool};
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config + scored_pool::Config {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::weight(0)]
pub fn candidate(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let _ = <scored_pool::Pallet<T>>::submit_candidacy(
T::Origin::from(Some(who.clone()).into())
);
Ok(())
}
}
}
Dependencies
This module depends on the System module.
License: Apache-2.0