mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +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:
@@ -112,8 +112,8 @@ pub fn create_validator_with_nominators<T: Config>(
|
||||
|
||||
assert_eq!(new_validators.len(), 1);
|
||||
assert_eq!(new_validators[0], v_stash, "Our validator was not selected!");
|
||||
assert_ne!(CounterForValidators::<T>::get(), 0);
|
||||
assert_ne!(CounterForNominators::<T>::get(), 0);
|
||||
assert_ne!(Validators::<T>::count(), 0);
|
||||
assert_ne!(Nominators::<T>::count(), 0);
|
||||
|
||||
// Give Era Points
|
||||
let reward = EraRewardPoints::<T::AccountId> {
|
||||
@@ -922,8 +922,8 @@ mod tests {
|
||||
let count_validators = Validators::<Test>::iter().count();
|
||||
let count_nominators = Nominators::<Test>::iter().count();
|
||||
|
||||
assert_eq!(count_validators, CounterForValidators::<Test>::get() as usize);
|
||||
assert_eq!(count_nominators, CounterForNominators::<Test>::get() as usize);
|
||||
assert_eq!(count_validators, Validators::<Test>::count() as usize);
|
||||
assert_eq!(count_nominators, Nominators::<Test>::count() as usize);
|
||||
|
||||
assert_eq!(count_validators, v as usize);
|
||||
assert_eq!(count_nominators, n as usize);
|
||||
|
||||
Reference in New Issue
Block a user