Enforce MaxEncodedLen impl for NposSolution (#11103)

* Fail if `MaxVoters` too small

* Fixing benchmarking test, better naming of error

* reverting accidental change

* use fully qualified syntax
no need to interate to calculate len

* Fail directly if too many voters
This commit is contained in:
Georges
2022-03-31 13:54:44 +01:00
committed by GitHub
parent 7bf19fa9c9
commit 0e0d0a677a
6 changed files with 40 additions and 4 deletions
@@ -119,12 +119,14 @@ pub enum Error {
SolutionTargetOverflow,
/// One of the index functions returned none.
SolutionInvalidIndex,
/// One of the page indices was invalid
/// One of the page indices was invalid.
SolutionInvalidPageIndex,
/// An error occurred in some arithmetic operation.
ArithmeticError(&'static str),
/// The data provided to create support map was invalid.
InvalidSupportEdge,
/// The number of voters is bigger than the `MaxVoters` bound.
TooManyVoters,
}
/// A type which is used in the API of this crate as a numeric weight of a vote, most often the