referrerpolicy=no-referrer-when-downgrade
pub trait Verifier {
    type Solution;
    type AccountId;
    type MaxWinnersPerPage: Get<u32>;
    type MaxBackersPerWinnerFinal: Get<u32>;
    type MaxBackersPerWinner: Get<u32>;

    // Required methods
    fn set_minimum_score(score: ElectionScore);
    fn queued_score() -> Option<ElectionScore>;
    fn ensure_claimed_score_improves(claimed_score: ElectionScore) -> bool;
    fn kill();
    fn get_queued_solution_page(
        page: PageIndex,
    ) -> Option<BoundedSupports<<Self as Verifier>::AccountId, <Self as Verifier>::MaxWinnersPerPage, <Self as Verifier>::MaxBackersPerWinner>>;
    fn verify_synchronous_multi(
        partial_solution: Vec<Self::Solution>,
        pages: Vec<PageIndex>,
        claimed_score: ElectionScore,
    ) -> Result<(), FeasibilityError>;
    fn force_set_single_page_valid(
        partial_supports: BoundedSupports<<Self as Verifier>::AccountId, <Self as Verifier>::MaxWinnersPerPage, <Self as Verifier>::MaxBackersPerWinner>,
        page: PageIndex,
        score: ElectionScore,
    );

    // Provided method
    fn verify_synchronous(
        partial_solution: Self::Solution,
        claimed_score: ElectionScore,
        page: PageIndex,
    ) -> Result<(), FeasibilityError> { ... }
}
Expand description

The interface of something that can verify solutions for other sub-pallets in the multi-block election pallet-network.

Required Associated Types§

Source

type Solution

The solution type.

Source

type AccountId

The account if type.

Source

type MaxWinnersPerPage: Get<u32>

Maximum number of winners that can be represented in each page.

A reasonable value for this should be the maximum number of winners that the election user (e.g. the staking pallet) could ever desire.

Source

type MaxBackersPerWinnerFinal: Get<u32>

Maximum number of backers, per winner, among all pages of an election.

This can only be checked at the very final step of verification.

Source

type MaxBackersPerWinner: Get<u32>

Maximum number of backers that each winner could have, per page.

Required Methods§

Source

fn set_minimum_score(score: ElectionScore)

Set the minimum score that is acceptable for any solution.

Henceforth, all solutions must have at least this degree of quality, single-page or multi-page.

Source

fn queued_score() -> Option<ElectionScore>

The score of the current best solution. None if there is none.

Source

fn ensure_claimed_score_improves(claimed_score: ElectionScore) -> bool

Check if the claimed score is sufficient to challenge the current queued solution, if any.

Source

fn kill()

Clear all storage items, there’s nothing else to do until further notice.

Source

fn get_queued_solution_page( page: PageIndex, ) -> Option<BoundedSupports<<Self as Verifier>::AccountId, <Self as Verifier>::MaxWinnersPerPage, <Self as Verifier>::MaxBackersPerWinner>>

Get a single page of the best verified solution, if any.

It is the responsibility of the call site to call this function with all appropriate page arguments.

Source

fn verify_synchronous_multi( partial_solution: Vec<Self::Solution>, pages: Vec<PageIndex>, claimed_score: ElectionScore, ) -> Result<(), FeasibilityError>

Perform synchronous feasibility check on the given multi-page solution.

Same semantics as Self::verify_synchronous, but for multi-page solutions.

Source

fn force_set_single_page_valid( partial_supports: BoundedSupports<<Self as Verifier>::AccountId, <Self as Verifier>::MaxWinnersPerPage, <Self as Verifier>::MaxBackersPerWinner>, page: PageIndex, score: ElectionScore, )

Force set a single page solution as the valid one.

Will erase any previous solution. Should only be used in case of emergency fallbacks, trusted governance solutions and so on.

Provided Methods§

Source

fn verify_synchronous( partial_solution: Self::Solution, claimed_score: ElectionScore, page: PageIndex, ) -> Result<(), FeasibilityError>

Perform the feasibility check on the given single-page solution.

This will perform:

  1. feasibility-check
  2. claimed score is correct and an improvement.
  3. bounds are respected

Corresponding snapshot (represented by page) is assumed to be available.

If all checks pass, the solution is also queued.

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§