I`m looking for an efficient way to purge StorageDoubleMap.
so lets assume I have some collection:
#[pallet::storage]
#[pallet::getter(fn provisions)]
pub type Provisions<T: Config> =
StorageDoubleMap<_, Twox64Concat, T::AccountId, Twox64Concat, TokenId, Balance, ValueQuery>;
That is filled with some data and now I want to remove all the entries effectively.
What I tried so far is:
#[pallet::weight(T::WeightInfo::claim_rewards())]
#[transactional]
pub fn finalize(origin: OriginFor<T>, limit: Option<u32>) -> DispatchResult {
ensure_root(origin)?;
let mut remove_counter = 0;
for prefix in [
Provisions::<T>::prefix_hash(),
] {
match child::kill_storage(&ChildInfo::new_default_from_vec(prefix), limit) {
KillStorageResult::AllRemoved(num_removed) |
KillStorageResult::SomeRemaining(num_removed) => {
if let Some(l) = limit {
remove_counter+=num_removed;
if remove_counter >= l {
Self::deposit_event(Event::PartiallyCleaned);
return Ok(().into())
}
}
}
};
}
Self::deposit_event(Event::Cleaned);
Ok(().into())
}
but it doesn't seem to work.
child::kill_storage
?