* add NamedReservableCurrency * move currency related trait and types into a new file * implement NamedReservableCurrency * remove empty reserves * Update frame/support/src/traits.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * fix build * bump year * add MaxReserves * repatriate_reserved_named should put reserved fund into named reserved * add tests * add some docs * fix warning * Update lib.rs * fix test * fix test * fix * fix * triggier CI * Move NamedReservableCurrency. * Use strongly bounded vec for reserves. * Fix test. * remove duplicated file * trigger CI * Make `ReserveIdentifier` assosicated type * add helpers * make ReserveIdentifier assosicated type * fix * update * trigger CI * Apply suggestions from code review Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * trigger CI * Apply suggestions from code review Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Gavin Wood <i@gavwood.com> Co-authored-by: Shaun Wang <spxwang@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 frame_support::{decl_module, dispatch};
use frame_system::ensure_signed;
use pallet_scored_pool::{self as scored_pool};
pub trait Config: scored_pool::Config {}
decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
#[weight = 0]
pub fn candidate(origin) -> dispatch::DispatchResult {
let who = ensure_signed(origin)?;
let _ = <scored_pool::Module<T>>::submit_candidacy(
T::Origin::from(Some(who.clone()).into())
);
Ok(())
}
}
}
Dependencies
This module depends on the System module.
License: Apache-2.0