mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 08:37:56 +00:00
Safe and sane multi-item storage removal (#11490)
* Fix overlay prefix removal result * Second part of the overlay prefix removal fix. * Report only items deleted from storage in clear_prefix * Fix kill_prefix * Formatting * Remove unused code * Fixes * Fixes * Introduce clear_prefix host function v3 * Formatting * Use v2 for now * Fixes * Formatting * Docs * Child prefix removal should also hide v3 for now * Fixes * Fixes * Formatting * Fixes * apply_to_keys_whle takes start_at * apply_to_keys_whle takes start_at * apply_to_keys_whle takes start_at * Cursor API; force limits * Use unsafe deprecated functions * Formatting * Fixes * Grumbles * Fixes * Docs * Some nitpicks 🙈 * Update primitives/externalities/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Formatting * Fixes * cargo fmt * Fixes * Update primitives/io/src/lib.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Formatting * Fixes Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
@@ -585,8 +585,11 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
/// Clear all era information for given era.
|
||||
pub(crate) fn clear_era_information(era_index: EraIndex) {
|
||||
#[allow(deprecated)]
|
||||
<ErasStakers<T>>::remove_prefix(era_index, None);
|
||||
#[allow(deprecated)]
|
||||
<ErasStakersClipped<T>>::remove_prefix(era_index, None);
|
||||
#[allow(deprecated)]
|
||||
<ErasValidatorPrefs<T>>::remove_prefix(era_index, None);
|
||||
<ErasValidatorReward<T>>::remove(era_index);
|
||||
<ErasRewardPoints<T>>::remove(era_index);
|
||||
@@ -984,9 +987,13 @@ impl<T: Config> ElectionDataProvider for Pallet<T> {
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn clear() {
|
||||
#[allow(deprecated)]
|
||||
<Bonded<T>>::remove_all(None);
|
||||
#[allow(deprecated)]
|
||||
<Ledger<T>>::remove_all(None);
|
||||
#[allow(deprecated)]
|
||||
<Validators<T>>::remove_all();
|
||||
#[allow(deprecated)]
|
||||
<Nominators<T>>::remove_all();
|
||||
|
||||
T::VoterList::unsafe_clear();
|
||||
@@ -1368,7 +1375,9 @@ impl<T: Config> SortedListProvider<T::AccountId> for UseNominatorsAndValidatorsM
|
||||
fn unsafe_clear() {
|
||||
// NOTE: Caller must ensure this doesn't lead to too many storage accesses. This is a
|
||||
// condition of SortedListProvider::unsafe_clear.
|
||||
#[allow(deprecated)]
|
||||
Nominators::<T>::remove_all();
|
||||
#[allow(deprecated)]
|
||||
Validators::<T>::remove_all();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,7 +557,9 @@ impl<'a, T: 'a + Config> Drop for InspectingSpans<'a, T> {
|
||||
|
||||
/// Clear slashing metadata for an obsolete era.
|
||||
pub(crate) fn clear_era_metadata<T: Config>(obsolete_era: EraIndex) {
|
||||
#[allow(deprecated)]
|
||||
<Pallet<T> as Store>::ValidatorSlashInEra::remove_prefix(&obsolete_era, None);
|
||||
#[allow(deprecated)]
|
||||
<Pallet<T> as Store>::NominatorSlashInEra::remove_prefix(&obsolete_era, None);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,11 @@ const SEED: u32 = 0;
|
||||
|
||||
/// This function removes all validators and nominators from storage.
|
||||
pub fn clear_validators_and_nominators<T: Config>() {
|
||||
#[allow(deprecated)]
|
||||
Validators::<T>::remove_all();
|
||||
|
||||
// whenever we touch nominators counter we should update `T::VoterList` as well.
|
||||
#[allow(deprecated)]
|
||||
Nominators::<T>::remove_all();
|
||||
|
||||
// NOTE: safe to call outside block production
|
||||
|
||||
Reference in New Issue
Block a user