referrerpolicy=no-referrer-when-downgrade
frame_election_provider_support

Trait NposSolver

Source
pub trait NposSolver {
    type AccountId: IdentifierT;
    type Accuracy: PerThing128;
    type Error: Debug + PartialEq;

    // Required methods
    fn solve(
        to_elect: usize,
        targets: Vec<Self::AccountId>,
        voters: Vec<(Self::AccountId, VoteWeight, impl Clone + IntoIterator<Item = Self::AccountId>)>,
    ) -> Result<ElectionResult<Self::AccountId, Self::Accuracy>, Self::Error>;
    fn weight<T: WeightInfo>(
        voters: u32,
        targets: u32,
        vote_degree: u32,
    ) -> Weight;
}
Expand description

Something that can compute the result to an NPoS solution.

Required Associated Types§

Source

type AccountId: IdentifierT

The account identifier type of this solver.

Source

type Accuracy: PerThing128

The accuracy of this solver. This will affect the accuracy of the output.

Source

type Error: Debug + PartialEq

The error type of this implementation.

Required Methods§

Source

fn solve( to_elect: usize, targets: Vec<Self::AccountId>, voters: Vec<(Self::AccountId, VoteWeight, impl Clone + IntoIterator<Item = Self::AccountId>)>, ) -> Result<ElectionResult<Self::AccountId, Self::Accuracy>, Self::Error>

Solve an NPoS solution with the given voters, targets, and select to_elect count of targets.

Source

fn weight<T: WeightInfo>(voters: u32, targets: u32, vote_degree: u32) -> Weight

Measure the weight used in the calculation of the solver.

  • voters is the number of voters.
  • targets is the number of targets.
  • vote_degree is the degree ie the maximum numbers of votes per voter.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<AccountId: IdentifierT, Accuracy: PerThing128> NposSolver for QuickDirtySolver<AccountId, Accuracy>

Source§

type AccountId = AccountId

Source§

type Accuracy = Accuracy

Source§

type Error = &'static str

Source§

impl<AccountId: IdentifierT, Accuracy: PerThing128, Balancing: Get<Option<BalancingConfig>>> NposSolver for PhragMMS<AccountId, Accuracy, Balancing>

Source§

type AccountId = AccountId

Source§

type Accuracy = Accuracy

Source§

type Error = Error

Source§

impl<AccountId: IdentifierT, Accuracy: PerThing128, Balancing: Get<Option<BalancingConfig>>> NposSolver for SequentialPhragmen<AccountId, Accuracy, Balancing>

Source§

type AccountId = AccountId

Source§

type Accuracy = Accuracy

Source§

type Error = Error