Crate pallet_bags_list[−][src]
Expand description
Bags-List Pallet
A semi-sorted list, where items hold an AccountId
based on some VoteWeight
. The AccountId
(id
for short) might be synonym to a voter
or nominator
in some context, and VoteWeight
signifies the chance of each id being included in the final SortedListProvider::iter
.
It implements frame_election_provider_support::SortedListProvider
to provide a semi-sorted
list of accounts to another pallet. It needs some other pallet to give it some information about
the weights of accounts via frame_election_provider_support::VoteWeightProvider
.
This pallet is not configurable at genesis. Whoever uses it should call appropriate functions of
the SortedListProvider
(e.g. on_insert
, or unsafe_regenerate
) at their genesis.
Goals
The data structure exposed by this pallet aims to be optimized for:
- insertions and removals.
- iteration over the top* N items by weight, where the precise ordering of items doesn’t particularly matter.
Details
- items are kept in bags, which are delineated by their range of weight (See
Config::BagThresholds
). - for iteration, bags are chained together from highest to lowest and elements within the bag are iterated from head to tail.
- items within a bag are iterated in order of insertion. Thus removing an item and re-inserting it will worsen its position in list iteration; this reduces incentives for some types of spam that involve consistently removing and inserting for better position. Further, ordering granularity is thus dictated by range between each bag threshold.
- if an item’s weight changes to a value no longer within the range of its current bag the item’s position will need to be updated by an external actor with rebag (update), or removal and insertion.
Re-exports
pub use pallet::*;
pub use weights::WeightInfo;
Modules
The migrations of this pallet.
Mock runtime for pallet-bags-lists tests.
Autogenerated weights for pallet_bags_list
Macros
Structs
The ONLY entry point of this module. All operations to the bags-list should happen through this interface. It is forbidden to access other module members directly.
A Node is the fundamental element comprising the doubly-linked list described by Bag
.
Enums
Functions
Given a certain vote weight, to which bag does it belong to?