Trait frame_election_provider_support::SortedListProvider[][src]

pub trait SortedListProvider<AccountId> {
    type Error;
    fn iter() -> Box<dyn Iterator<Item = AccountId>>
Notable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
    R: Read + ?Sized
impl<W> Write for Box<W, Global> where
    W: Write + ?Sized
impl<F, A> Future for Box<F, A> where
    F: Future + Unpin + ?Sized,
    A: Allocator + 'static, 
type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
    I: Iterator + ?Sized,
    A: Allocator
type Item = <I as Iterator>::Item;
fn count() -> u32;
fn contains(id: &AccountId) -> bool;
fn on_insert(id: AccountId, weight: VoteWeight) -> Result<(), Self::Error>;
fn on_update(id: &AccountId, weight: VoteWeight);
fn on_remove(id: &AccountId);
fn unsafe_regenerate(
        all: impl IntoIterator<Item = AccountId>,
        weight_of: Box<dyn Fn(&AccountId) -> VoteWeight>
    ) -> u32;
fn unsafe_clear();
fn sanity_check() -> Result<(), &'static str>; fn weight_update_worst_case(
        _who: &AccountId,
        _is_increase: bool
    ) -> VoteWeight { ... } }
Expand description

A utility trait for something to implement ElectionDataProvider in a sensible way.

This is generic over AccountId and it can represent a validator, a nominator, or any other entity.

To simplify the trait, the VoteWeight is hardcoded as the weight of each entity. The weights are ascending, the higher, the better. In the long term, if this trait ends up having use cases outside of the election context, it is easy enough to make it generic over the VoteWeight.

Something that implements this trait will do a best-effort sort over ids, and thus can be used on the implementing side of ElectionDataProvider.

Associated Types

The list’s error type.

Required methods

An iterator over the list, which can have take called on it.

The current count of ids in the list.

Return true if the list already contains id.

Hook for inserting a new id.

Hook for updating a single id.

Hook for removing am id from the list.

Regenerate this list from scratch. Returns the count of items inserted.

This should typically only be used at a runtime upgrade.


This function should be called with care, regenerate will remove the current list write the new list, which can lead to too many storage accesses, exhausting the block weight.

Remove all items from the list.


This function should never be called in production settings because it can lead to an unbounded amount of storage accesses.

Sanity check internal state of list. Only meant for debug compilation.

Provided methods

If who changes by the returned amount they are guaranteed to have a worst case change in their list position.