Use updated bags list: Companion to #10997 (#5065)

* Use updated bags list: Companion to #10997

* Use Score, not Value

* update lockfile for {"substrate"}

* Fix match_types

* Fix

Co-authored-by: parity-processbot <>
This commit is contained in:
Zeke Mostov
2022-03-10 09:02:15 +00:00
committed by GitHub
parent 49f7e5cce4
commit b13bb87870
8 changed files with 180 additions and 180 deletions
+5 -9
View File
@@ -17,7 +17,7 @@
//! Code for elections.
use super::{BlockExecutionWeight, BlockLength, BlockWeights};
use frame_election_provider_support::{SortedListProvider, VoteWeight};
use frame_election_provider_support::SortedListProvider;
use frame_support::{
parameter_types,
weights::{DispatchClass, Weight},
@@ -76,6 +76,7 @@ impl<T: pallet_bags_list::Config + pallet_staking::Config> SortedListProvider<T:
for UseNominatorsAndUpdateBagsList<T>
{
type Error = pallet_bags_list::Error;
type Score = <T as pallet_bags_list::Config>::Score;
fn iter() -> Box<dyn Iterator<Item = T::AccountId>> {
Box::new(pallet_staking::Nominators::<T>::iter().map(|(n, _)| n))
@@ -89,11 +90,11 @@ impl<T: pallet_bags_list::Config + pallet_staking::Config> SortedListProvider<T:
pallet_bags_list::Pallet::<T>::contains(id)
}
fn on_insert(id: T::AccountId, weight: VoteWeight) -> Result<(), Self::Error> {
fn on_insert(id: T::AccountId, weight: Self::Score) -> Result<(), Self::Error> {
pallet_bags_list::Pallet::<T>::on_insert(id, weight)
}
fn on_update(id: &T::AccountId, new_weight: VoteWeight) {
fn on_update(id: &T::AccountId, new_weight: Self::Score) {
pallet_bags_list::Pallet::<T>::on_update(id, new_weight);
}
@@ -103,7 +104,7 @@ impl<T: pallet_bags_list::Config + pallet_staking::Config> SortedListProvider<T:
fn unsafe_regenerate(
all: impl IntoIterator<Item = T::AccountId>,
weight_of: Box<dyn Fn(&T::AccountId) -> VoteWeight>,
weight_of: Box<dyn Fn(&T::AccountId) -> Self::Score>,
) -> u32 {
pallet_bags_list::Pallet::<T>::unsafe_regenerate(all, weight_of)
}
@@ -115,9 +116,4 @@ impl<T: pallet_bags_list::Config + pallet_staking::Config> SortedListProvider<T:
fn unsafe_clear() {
pallet_bags_list::Pallet::<T>::unsafe_clear()
}
#[cfg(feature = "runtime-benchmarks")]
fn weight_update_worst_case(who: &T::AccountId, is_increase: bool) -> VoteWeight {
pallet_bags_list::Pallet::<T>::weight_update_worst_case(who, is_increase)
}
}