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:
Ayevbeosa Iyamu
2021-12-07 10:21:27 +01:00
committed by GitHub
parent 9e9e18b161
commit 56fb1cfbb6
9 changed files with 74 additions and 82 deletions
@@ -27,6 +27,7 @@ pub async fn execute<Runtime: crate::RuntimeT, Block: BlockT + DeserializeOwned>
ws_url: String,
) {
use frame_support::storage::generator::StorageMap;
let mut ext = Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: ws_url.to_string().into(),
@@ -38,10 +39,10 @@ pub async fn execute<Runtime: crate::RuntimeT, Block: BlockT + DeserializeOwned>
}))
.inject_hashed_prefix(&<pallet_staking::Bonded<Runtime>>::prefix_hash())
.inject_hashed_prefix(&<pallet_staking::Ledger<Runtime>>::prefix_hash())
.inject_hashed_prefix(&<pallet_staking::Validators<Runtime>>::prefix_hash())
.inject_hashed_prefix(&<pallet_staking::Nominators<Runtime>>::prefix_hash())
.inject_hashed_key(&<pallet_staking::CounterForNominators<Runtime>>::hashed_key())
.inject_hashed_key(&<pallet_staking::CounterForValidators<Runtime>>::hashed_key())
.inject_hashed_prefix(&<pallet_staking::Validators<Runtime>>::map_storage_final_prefix())
.inject_hashed_prefix(&<pallet_staking::Nominators<Runtime>>::map_storage_final_prefix())
.inject_hashed_key(&<pallet_staking::Validators<Runtime>>::counter_storage_final_key())
.inject_hashed_key(&<pallet_staking::Nominators<Runtime>>::counter_storage_final_key())
.build()
.await
.unwrap();