This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: clear also JobRegistration since requirements format changed
- Loading branch information
Showing
6 changed files
with
129 additions
and
97 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 |
---|---|---|
@@ -1,18 +1,31 @@ | ||
use frame_support::{traits::GetStorageVersion, weights::Weight}; | ||
use frame_support::{ | ||
traits::{GetStorageVersion, StorageVersion}, | ||
weights::Weight, | ||
}; | ||
use sp_core::Get; | ||
|
||
use super::*; | ||
|
||
pub fn migrate_to_v2<T: Config<I>, I: 'static>() -> Weight { | ||
let onchain_version = Pallet::<T, I>::on_chain_storage_version(); | ||
if onchain_version < crate::STORAGE_VERSION { | ||
let mut count = 0u32; | ||
count += AssetIndex::<T, I>::clear(100, None).loops; | ||
count += ReverseAssetIndex::<T, I>::clear(100, None).loops; | ||
pub fn migrate<T: Config<I>, I: 'static>() -> Weight { | ||
let migrations: [&dyn Fn() -> Weight; STORAGE_VERSION_ - 1] = [&migrate_to_v2::<T, I>]; | ||
|
||
STORAGE_VERSION.put::<Pallet<T, I>>(); | ||
T::DbWeight::get().reads_writes((count + 1).into(), (count + 1).into()) | ||
} else { | ||
Weight::zero() | ||
let onchain_version = Pallet::<T, I>::on_chain_storage_version(); | ||
let mut weight: Weight = Default::default(); | ||
for (i, f) in migrations.iter().enumerate() { | ||
// correct index since we start with version 2 but i is 0-based | ||
if onchain_version < StorageVersion::new((i + 2).try_into().unwrap()) { | ||
weight += f(); | ||
} | ||
} | ||
|
||
STORAGE_VERSION.put::<Pallet<T, I>>(); | ||
weight + T::DbWeight::get().writes(1) | ||
} | ||
|
||
fn migrate_to_v2<T: Config<I>, I: 'static>() -> Weight { | ||
let mut count = 0u32; | ||
count += AssetIndex::<T, I>::clear(100, None).loops; | ||
count += ReverseAssetIndex::<T, I>::clear(100, None).loops; | ||
|
||
T::DbWeight::get().reads_writes((count + 1).into(), (count + 1).into()) | ||
} |
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