File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -256,5 +256,7 @@ mod errors {
256256 CannotAffordLockCost ,
257257 /// exceeded the rate limit for associating an EVM key.
258258 EvmKeyAssociateRateLimitExceeded ,
259+ /// The UID map for the subnet could not be cleared
260+ UidMapCouldNotBeCleared ,
259261 }
260262}
Original file line number Diff line number Diff line change @@ -352,6 +352,21 @@ impl<T: Config> Pallet<T> {
352352 }
353353 }
354354
355+ // Clear the UID map for the subnet
356+ let clear_result = Uids :: < T > :: clear_prefix ( netuid, u32:: MAX , None ) ;
357+ // Shouldn't happen, but possible.
358+ ensure ! (
359+ clear_result. maybe_cursor. is_none( ) ,
360+ Error :: <T >:: UidMapCouldNotBeCleared
361+ ) ;
362+
363+ // Insert the new UIDs
364+ for ( old_uid, new_uid) in & old_to_new_uid {
365+ // Get the hotkey using Keys map and new UID.
366+ let hotkey = Keys :: < T > :: get ( netuid, * new_uid as u16 ) ;
367+ Uids :: < T > :: insert ( netuid, hotkey, * new_uid as u16 ) ;
368+ }
369+
355370 // Update the subnet's uid count to reflect the new maximum
356371 SubnetworkN :: < T > :: insert ( netuid, max_n) ;
357372 }
You can’t perform that action at this time.
0 commit comments