Files
pezkuwi-sdk/bizinikiwi/pezframe/scored-pool/README.md
T
pezkuwichain 3139ffa25e fix: Complete snowbridge pezpallet rebrand and critical bug fixes
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs)
- pallet/ directories → pezpallet/ (4 locations)
- Fixed pezpallet.rs self-include recursion bug
- Fixed sc-chain-spec hardcoded crate name in derive macro
- Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API)
- Added BizinikiwiConfig type alias for zombienet tests
- Deleted obsolete session state files

Verified: pezsnowbridge-pezpallet-*, pezpallet-staking,
pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
2025-12-16 09:57:23 +03:00

74 lines
2.6 KiB
Markdown

# 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.
- [`scored_pool::Trait`](https://docs.rs/pezpallet-scored-pool/latest/pallet_scored_pool/trait.Config.html)
- [`Call`](https://docs.rs/pezpallet-scored-pool/latest/pallet_scored_pool/enum.Call.html)
- [`Module`](https://docs.rs/pezpallet-scored-pool/latest/pallet_scored_pool/struct.Module.html)
## 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 into `Members`.
## Usage
```rust
use pallet_scored_pool::{self as scored_pool};
#[frame_support::pezpallet]
pub mod pezpallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pezpallet::config]
pub trait Config: frame_system::Config + scored_pool::Config {}
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
#[pezpallet::weight(0)]
pub fn candidate(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let _ = <scored_pool::Pezpallet<T>>::submit_candidacy(
T::RuntimeOrigin::from(Some(who.clone()).into())
);
Ok(())
}
}
}
```
## Dependencies
This module depends on the [System module](https://docs.rs/pezframe-system/latest/frame_system/).
License: Apache-2.0