Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
605c893
Move `sp-npos-elections-solution-type`
Mar 6, 2022
020cd99
Fixing tests
Mar 6, 2022
676923d
Fixing tests
Mar 7, 2022
7c31687
Fixing cargo.toml for std configuration
Mar 7, 2022
79538d2
Implementing `MaxEncodedLen`
Mar 7, 2022
4dac1d2
Full implementation of `max_encoded_len`
Mar 8, 2022
38dc2fa
Fixing implementation bug
Mar 8, 2022
d034a12
Merge branch 'paritytech:master' into election-solution-bounded-move
georgesdib Mar 11, 2022
bb71738
fmt
Mar 11, 2022
dbf082b
Merge branch 'paritytech:master' into election-solution-bounded-move
georgesdib Mar 11, 2022
4ba1eea
Committing suggested changes
Mar 12, 2022
4fb9569
Merge branch 'election-solution-bounded-move' of https://github.com/g…
Mar 12, 2022
a076c9b
Removing unneeded imports
Mar 12, 2022
505f5aa
Implementing `MaxEncodedLen`
Mar 7, 2022
dff988d
Full implementation of `max_encoded_len`
Mar 8, 2022
4c37fbb
Fixing implementation bug
Mar 8, 2022
2a6f778
rebase
Mar 12, 2022
45d778c
Move `NposSolution` to frame
Mar 13, 2022
e9db59e
Merge branch 'master' into support-to-frame
Mar 14, 2022
626878d
Implementing `MaxEncodedLen`
Mar 7, 2022
d57cd90
Full implementation of `max_encoded_len`
Mar 8, 2022
6759535
Fixing implementation bug
Mar 8, 2022
563d00d
Merge branch 'election-solution-bounded' of https://github.com/george…
Mar 14, 2022
64b083a
Fixing test
Mar 14, 2022
529b5cd
Merge master
Mar 16, 2022
5b01e89
Removing unneeded dependencies
Mar 16, 2022
51dd862
Merge master
Mar 19, 2022
6848ce1
`VoterSnapshotPerBlock` -> `MaxElectingVoters`
Mar 19, 2022
0883324
rename `SizeBound` to `MaxVoters`
Mar 20, 2022
d3b06c6
Removing TODO and change bound
Mar 20, 2022
0cd8944
renaming `size_bound` to `max_voters`
Mar 20, 2022
38c0cf5
Enabling tests for `solution-type`
Mar 20, 2022
084e586
Adding tests for `MaxEncodedLen` of solution_type
Mar 20, 2022
0578224
Better rustdocs. Better indenting and comments.
Mar 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Full implementation of max_encoded_len
  • Loading branch information
Georges Dib committed Mar 12, 2022
commit dff988da15000d4b512616a3d88f993807023a41
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,14 @@ pub(crate) fn generate(def: crate::SolutionDef) -> Result<TokenStream2> {
impl _npos::codec::MaxEncodedLen for #ident {
fn max_encoded_len() -> usize {
use frame_support::traits::Get;
use _npos::codec::Encode;
let s: u32 = #size_bound::get();
s as usize
let max_element_size = #voter_type::max_encoded_len()
.max(#target_type::max_encoded_len()
.max(#weight_type::max_encoded_len()));
#count.saturating_mul(
_npos::codec::Compact(s).encoded_size()
.saturating_add((s as usize).saturating_mul(max_element_size)))
}
}
impl<'a> _npos::sp_std::convert::TryFrom<&'a [__IndexAssignment]> for #ident {
Expand Down