mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 02:48:03 +00:00
Used CountedStorageMap in pallet-staking (#10233)
* Removed counters and used CountedStorageMap instead. * Little refactoring * Update frame/staking/src/migrations.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Removed redundant code to update counter for validator & nominator. * Removed redundant code to update counter for validator & nominator. * Removed unreachable code to inject the hashed prefix for nominator & validator. * Removed redundant check for nominator & validator count. * Generated `fn prefix_hash` for `CountedStorageMap`. * Applied changes from `cargo fmt` * Possible correct implementation of migration code * Implemented fn module_prefix, storage_prefix and prefix_hash. * Removed counted_map.rs * Renamed `fn storage_prefix` to `storage_counter_prefix`. * Update frame/support/src/storage/types/counted_map.rs * Update frame/bags-list/remote-tests/src/snapshot.rs * Update frame/support/src/storage/types/counted_map.rs * Fixed errors. Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -36,12 +36,11 @@ const SEED: u32 = 0;
|
||||
|
||||
/// This function removes all validators and nominators from storage.
|
||||
pub fn clear_validators_and_nominators<T: Config>() {
|
||||
Validators::<T>::remove_all(None);
|
||||
CounterForValidators::<T>::kill();
|
||||
Validators::<T>::remove_all();
|
||||
|
||||
// whenever we touch nominators counter we should update `T::SortedListProvider` as well.
|
||||
Nominators::<T>::remove_all(None);
|
||||
CounterForNominators::<T>::kill();
|
||||
Nominators::<T>::remove_all();
|
||||
|
||||
// NOTE: safe to call outside block production
|
||||
T::SortedListProvider::unsafe_clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user