Skip to content

Commit bc85189

Browse files
committed
rework
1 parent fc84df2 commit bc85189

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

pallets/subtensor/src/migrations/migrate_remove_total_hotkey_coldkey_stakes_this_interval.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,31 @@ pub fn migrate_remove_total_hotkey_coldkey_stakes_this_interval<T: Config>() ->
2222
let storage_name = twox_128(b"TotalHotkeyColdkeyStakesThisInterval");
2323
let prefix = [pallet_name, storage_name].concat();
2424

25-
// Try to remove all entries from the storage, if some entries are remaining,
26-
// the migration will re-run again on next blocks until all entries are removed.
25+
// Remove all entries.
2726
let removed_entries_count = match clear_prefix(&prefix, Some(u32::MAX)) {
28-
KillStorageResult::AllRemoved(removed) => {
29-
// Mark migration as completed
30-
HasMigrationRun::<T>::insert(&migration_name_bytes, true);
31-
weight = weight.saturating_add(T::DbWeight::get().writes(1));
32-
33-
log::info!(
34-
"Migration '{:?}' completed successfully. {:?} entries removed.",
35-
migration_name,
36-
removed
37-
);
38-
removed
39-
}
27+
KillStorageResult::AllRemoved(removed) => removed as u64,
4028
KillStorageResult::SomeRemaining(removed) => {
41-
log::info!(
42-
"Migration '{:?}' completed partially. {:?} entries removed.",
43-
migration_name,
44-
removed
45-
);
46-
removed
29+
log::info!("Failed to remove all entries from {:?}", migration_name);
30+
removed as u64
4731
}
4832
};
4933

50-
weight.saturating_add(T::DbWeight::get().writes(removed_entries_count as u64))
34+
weight = weight.saturating_add(T::DbWeight::get().writes(removed_entries_count as u64));
35+
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+
45+
log::info!(
46+
"Migration '{:?}' completed successfully. {:?} entries removed.",
47+
migration_name,
48+
removed_entries_count
49+
);
50+
51+
weight
5152
}

0 commit comments

Comments
 (0)