Skip to content

Commit 6bcb63b

Browse files
committed
set migration as ran only if all entry removed
1 parent ce1c35d commit 6bcb63b

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

pallets/subtensor/src/migrations/migrate_remove_total_hotkey_coldkey_stakes_this_interval.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,23 @@ pub fn migrate_remove_total_hotkey_coldkey_stakes_this_interval<T: Config>() ->
2424

2525
// Remove all entries.
2626
let removed_entries_count = match clear_prefix(&prefix, Some(u32::MAX)) {
27-
KillStorageResult::AllRemoved(removed) => removed as u64,
27+
KillStorageResult::AllRemoved(removed) => {
28+
log::info!("Removed all entries from {:?}.", storage_name);
29+
30+
// Mark migration as completed
31+
HasMigrationRun::<T>::insert(&migration_name_bytes, true);
32+
weight = weight.saturating_add(T::DbWeight::get().writes(1));
33+
34+
removed as u64
35+
}
2836
KillStorageResult::SomeRemaining(removed) => {
29-
log::info!("Failed to remove all entries from {:?}", migration_name);
37+
log::info!("Failed to remove all entries from {:?}", storage_name);
3038
removed as u64
3139
}
3240
};
3341

3442
weight = weight.saturating_add(T::DbWeight::get().writes(removed_entries_count as u64));
3543

36-
log::info!(
37-
"Removed {:?} entries from TotalHotkeyColdkeyStakesThisInterval.",
38-
removed_entries_count
39-
);
40-
41-
// Mark migration as completed
42-
HasMigrationRun::<T>::insert(&migration_name_bytes, true);
43-
weight = weight.saturating_add(T::DbWeight::get().writes(1));
44-
4544
log::info!(
4645
"Migration '{:?}' completed successfully. {:?} entries removed.",
4746
migration_name,

0 commit comments

Comments
 (0)