@@ -22,30 +22,31 @@ pub fn migrate_remove_total_hotkey_coldkey_stakes_this_interval<T: Config>() ->
22
22
let storage_name = twox_128 ( b"TotalHotkeyColdkeyStakesThisInterval" ) ;
23
23
let prefix = [ pallet_name, storage_name] . concat ( ) ;
24
24
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.
27
26
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 ,
40
28
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
47
31
}
48
32
} ;
49
33
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
51
52
}
0 commit comments