Skip to content

Commit

Permalink
im-online removal cleanup: remove off-chain storage (paritytech#2290)
Browse files Browse the repository at this point in the history
This is a follow-up for `im-online` pallet removal that is cleaning up
its off-chain storage. Must be merged no earlier than paritytech#2265 is enacted.
Related: paritytech#1964

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
  • Loading branch information
s0me0ne-unkn0wn and bkchr committed Feb 19, 2024
1 parent ac41ea8 commit 11ace08
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions substrate/frame/im-online/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ pub mod v1 {
}
}

/// Clears the pallet's offchain storage.
///
/// Must be put in `OffchainWorkerApi::offchain_worker` after
/// the pallet was removed.
pub fn clear_offchain_storage(validator_set_size: u32) {
(0..validator_set_size).for_each(|idx| {
let key = {
let mut key = DB_PREFIX.to_vec();
key.extend(idx.encode());
key
};
sp_runtime::offchain::storage::StorageValueRef::persistent(&key).clear();
});
}

#[cfg(all(feature = "try-runtime", test))]
mod test {
use super::*;
Expand Down

0 comments on commit 11ace08

Please sign in to comment.