mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Fix pallet bags list and doc (#10231)
* fix bags list * improve doc * doc * inner doc * fix test * Update docs in frame/election-provider-support/src/lib.rs * fix staking impl * prepend unsafe to clear and regenerate * fix test Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
798e01bf9b
commit
9756615d5b
@@ -40,7 +40,7 @@ pub mod v8 {
|
||||
if StorageVersion::<T>::get() == crate::Releases::V7_0_0 {
|
||||
crate::log!(info, "migrating staking to Releases::V8_0_0");
|
||||
|
||||
let migrated = T::SortedListProvider::regenerate(
|
||||
let migrated = T::SortedListProvider::unsafe_regenerate(
|
||||
Nominators::<T>::iter().map(|(id, _)| id),
|
||||
Pallet::<T>::weight_of_fn(),
|
||||
);
|
||||
|
||||
@@ -971,7 +971,7 @@ impl<T: Config> ElectionDataProvider<T::AccountId, BlockNumberFor<T>> for Pallet
|
||||
<Nominators<T>>::remove_all(None);
|
||||
<CounterForNominators<T>>::kill();
|
||||
<CounterForValidators<T>>::kill();
|
||||
let _ = T::SortedListProvider::clear(None);
|
||||
T::SortedListProvider::unsafe_clear();
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -1299,7 +1299,7 @@ impl<T: Config> SortedListProvider<T::AccountId> for UseNominatorsMap<T> {
|
||||
fn on_remove(_: &T::AccountId) {
|
||||
// nothing to do on remove.
|
||||
}
|
||||
fn regenerate(
|
||||
fn unsafe_regenerate(
|
||||
_: impl IntoIterator<Item = T::AccountId>,
|
||||
_: Box<dyn Fn(&T::AccountId) -> VoteWeight>,
|
||||
) -> u32 {
|
||||
@@ -1309,13 +1309,10 @@ impl<T: Config> SortedListProvider<T::AccountId> for UseNominatorsMap<T> {
|
||||
fn sanity_check() -> Result<(), &'static str> {
|
||||
Ok(())
|
||||
}
|
||||
fn clear(maybe_count: Option<u32>) -> u32 {
|
||||
Nominators::<T>::remove_all(maybe_count);
|
||||
if let Some(count) = maybe_count {
|
||||
CounterForNominators::<T>::mutate(|noms| *noms - count);
|
||||
count
|
||||
} else {
|
||||
CounterForNominators::<T>::take()
|
||||
}
|
||||
fn unsafe_clear() {
|
||||
// NOTE: Caller must ensure this doesn't lead to too many storage accesses. This is a
|
||||
// condition of SortedListProvider::unsafe_clear.
|
||||
Nominators::<T>::remove_all(None);
|
||||
CounterForNominators::<T>::take();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ pub fn clear_validators_and_nominators<T: Config>() {
|
||||
// whenever we touch nominators counter we should update `T::SortedListProvider` as well.
|
||||
Nominators::<T>::remove_all(None);
|
||||
CounterForNominators::<T>::kill();
|
||||
let _ = T::SortedListProvider::clear(None);
|
||||
// NOTE: safe to call outside block production
|
||||
T::SortedListProvider::unsafe_clear();
|
||||
}
|
||||
|
||||
/// Grab a funded user.
|
||||
|
||||
Reference in New Issue
Block a user