-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: 'AuthorisedCaller' storage item is removed
- Loading branch information
1 parent
9e86512
commit a0328fc
Showing
7 changed files
with
82 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use frame_support::{migration, traits::OnRuntimeUpgrade}; | ||
use log; | ||
|
||
use super::*; | ||
|
||
const LOG_TARGET: &str = "ddc-payouts"; | ||
|
||
pub mod v1 { | ||
use frame_support::pallet_prelude::*; | ||
|
||
use super::*; | ||
|
||
pub fn migrate_to_v1<T: Config>() -> Weight { | ||
let on_chain_version = Pallet::<T>::on_chain_storage_version(); | ||
let current_version = Pallet::<T>::current_storage_version(); | ||
|
||
log::info!( | ||
target: LOG_TARGET, | ||
"Running migration with current storage version {:?} / onchain {:?}", | ||
current_version, | ||
on_chain_version | ||
); | ||
|
||
if on_chain_version == 0 && current_version == 1 { | ||
log::info!(target: LOG_TARGET, "Running migration to v1."); | ||
|
||
let res = migration::clear_storage_prefix( | ||
<Pallet<T>>::name().as_bytes(), | ||
b"AuthorisedCaller", | ||
b"", | ||
None, | ||
None, | ||
); | ||
|
||
log::info!( | ||
target: LOG_TARGET, | ||
"Cleared '{}' entries from 'AuthorisedCaller' storage prefix.", | ||
res.unique | ||
); | ||
|
||
if res.maybe_cursor.is_some() { | ||
log::error!( | ||
target: LOG_TARGET, | ||
"Storage prefix 'AuthorisedCaller' is not completely cleared." | ||
); | ||
} | ||
|
||
// Update storage version. | ||
StorageVersion::new(1).put::<Pallet<T>>(); | ||
log::info!( | ||
target: LOG_TARGET, | ||
"Storage migrated to version {:?}", | ||
current_version | ||
); | ||
|
||
T::DbWeight::get().reads_writes(1, res.unique.into()) | ||
} else { | ||
log::info!(target: LOG_TARGET, " >>> Unused migration!"); | ||
T::DbWeight::get().reads(1) | ||
} | ||
} | ||
|
||
pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>); | ||
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> { | ||
fn on_runtime_upgrade() -> Weight { | ||
migrate_to_v1::<T>() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.