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§
Sourcetype MaxWinnersPerPage: Get<u32>
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.
Sourcetype MaxBackersPerWinnerFinal: Get<u32>
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.
Sourcetype MaxBackersPerWinner: Get<u32>
type MaxBackersPerWinner: Get<u32>
Maximum number of backers that each winner could have, per page.
Required Methods§
Sourcefn set_minimum_score(score: ElectionScore)
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.
Sourcefn queued_score() -> Option<ElectionScore>
fn queued_score() -> Option<ElectionScore>
The score of the current best solution. None
if there is none.
Sourcefn ensure_claimed_score_improves(claimed_score: ElectionScore) -> bool
fn ensure_claimed_score_improves(claimed_score: ElectionScore) -> bool
Check if the claimed score is sufficient to challenge the current queued solution, if any.
Sourcefn get_queued_solution_page(
page: PageIndex,
) -> Option<BoundedSupports<<Self as Verifier>::AccountId, <Self as Verifier>::MaxWinnersPerPage, <Self as Verifier>::MaxBackersPerWinner>>
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.
Sourcefn verify_synchronous_multi(
partial_solution: Vec<Self::Solution>,
pages: Vec<PageIndex>,
claimed_score: ElectionScore,
) -> Result<(), FeasibilityError>
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.
Sourcefn force_set_single_page_valid(
partial_supports: BoundedSupports<<Self as Verifier>::AccountId, <Self as Verifier>::MaxWinnersPerPage, <Self as Verifier>::MaxBackersPerWinner>,
page: PageIndex,
score: ElectionScore,
)
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§
Sourcefn verify_synchronous(
partial_solution: Self::Solution,
claimed_score: ElectionScore,
page: PageIndex,
) -> Result<(), FeasibilityError>
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:
- feasibility-check
- claimed score is correct and an improvement.
- 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.