@@ -169,7 +169,20 @@ impl<T: Config> Pallet<T> {
169
169
weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads_writes ( 2 , 2 ) ) ;
170
170
}
171
171
172
- // 4. Swap total coldkey stake.
172
+ // 4. Swap StakeDeltaSinceLastEmissionDrain
173
+ for hotkey in StakingHotkeys :: < T > :: get ( old_coldkey) {
174
+ let old_stake_delta = StakeDeltaSinceLastEmissionDrain :: < T > :: get ( & hotkey, old_coldkey) ;
175
+ let new_stake_delta = StakeDeltaSinceLastEmissionDrain :: < T > :: get ( & hotkey, new_coldkey) ;
176
+ StakeDeltaSinceLastEmissionDrain :: < T > :: insert (
177
+ & hotkey,
178
+ new_coldkey,
179
+ new_stake_delta. saturating_add ( old_stake_delta) ,
180
+ ) ;
181
+ StakeDeltaSinceLastEmissionDrain :: < T > :: remove ( & hotkey, old_coldkey) ;
182
+ weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads_writes ( 2 , 2 ) ) ;
183
+ }
184
+
185
+ // 5. Swap total coldkey stake.
173
186
// TotalColdkeyStake: MAP ( coldkey ) --> u64 | Total stake of the coldkey.
174
187
let old_coldkey_stake: u64 = TotalColdkeyStake :: < T > :: get ( old_coldkey) ;
175
188
// Get the stake of the new coldkey.
@@ -183,7 +196,7 @@ impl<T: Config> Pallet<T> {
183
196
) ;
184
197
weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads_writes ( 2 , 2 ) ) ;
185
198
186
- // 5 . Swap StakingHotkeys.
199
+ // 6 . Swap StakingHotkeys.
187
200
// StakingHotkeys: MAP ( coldkey ) --> Vec<hotkeys> | Hotkeys staking for the coldkey.
188
201
let old_staking_hotkeys: Vec < T :: AccountId > = StakingHotkeys :: < T > :: get ( old_coldkey) ;
189
202
let mut new_staking_hotkeys: Vec < T :: AccountId > = StakingHotkeys :: < T > :: get ( new_coldkey) ;
@@ -197,7 +210,7 @@ impl<T: Config> Pallet<T> {
197
210
StakingHotkeys :: < T > :: insert ( new_coldkey, new_staking_hotkeys) ;
198
211
weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads_writes ( 2 , 2 ) ) ;
199
212
200
- // 6 . Swap hotkey owners.
213
+ // 7 . Swap hotkey owners.
201
214
// Owner: MAP ( hotkey ) --> coldkey | Owner of the hotkey.
202
215
// OwnedHotkeys: MAP ( coldkey ) --> Vec<hotkeys> | Hotkeys owned by the coldkey.
203
216
let old_owned_hotkeys: Vec < T :: AccountId > = OwnedHotkeys :: < T > :: get ( old_coldkey) ;
@@ -216,7 +229,7 @@ impl<T: Config> Pallet<T> {
216
229
OwnedHotkeys :: < T > :: insert ( new_coldkey, new_owned_hotkeys) ;
217
230
weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads_writes ( 2 , 2 ) ) ;
218
231
219
- // 7 . Transfer remaining balance.
232
+ // 8 . Transfer remaining balance.
220
233
// Balance: MAP ( coldkey ) --> u64 | Balance of the coldkey.
221
234
// Transfer any remaining balance from old_coldkey to new_coldkey
222
235
let remaining_balance = Self :: get_coldkey_balance ( old_coldkey) ;
0 commit comments