@@ -18,8 +18,15 @@ fn swap_pending_emissions<T: Config>(
18
18
PendingdHotkeyEmission :: < T > :: remove ( old_hotkey) ;
19
19
weight. saturating_accrue ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
20
20
21
+ // Get any existing pending emissions for the new hotkey
22
+ let existing_new_pending_emissions = PendingdHotkeyEmission :: < T > :: get ( new_hotkey) ;
23
+ weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads ( 1 ) ) ;
24
+
21
25
// Add the pending emissions for the new hotkey
22
- PendingdHotkeyEmission :: < T > :: insert ( new_hotkey, pending_emissions) ;
26
+ PendingdHotkeyEmission :: < T > :: insert (
27
+ new_hotkey,
28
+ pending_emissions. saturating_add ( existing_new_pending_emissions) ,
29
+ ) ;
23
30
weight. saturating_accrue ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
24
31
25
32
weight
@@ -40,8 +47,8 @@ fn unstake_old_hotkey_and_move_to_pending<T: Config>(
40
47
let null_account = DefaultAccount :: < T > :: get ( ) ;
41
48
weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads ( 1 ) ) ;
42
49
43
- // Get the pending emissions for the new hotkey
44
- let pending_emissions = PendingdHotkeyEmission :: < T > :: get ( new_hotkey ) ;
50
+ // Get the pending emissions for the OLD hotkey
51
+ let pending_emissions_old : u64 = PendingdHotkeyEmission :: < T > :: get ( old_hotkey ) ;
45
52
weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads ( 1 ) ) ;
46
53
47
54
// Get the stake for the 0x000 key
@@ -71,8 +78,17 @@ fn unstake_old_hotkey_and_move_to_pending<T: Config>(
71
78
TotalStake :: < T > :: put ( TotalStake :: < T > :: get ( ) . saturating_sub ( null_stake) ) ;
72
79
weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads_writes ( 1 , 1 ) ) ;
73
80
74
- // Add stake to the pending emissions for the new hotkey
75
- PendingdHotkeyEmission :: < T > :: insert ( new_hotkey, pending_emissions. saturating_add ( null_stake) ) ;
81
+ // Get the pending emissions for the NEW hotkey
82
+ let pending_emissions_new: u64 = PendingdHotkeyEmission :: < T > :: get ( new_hotkey) ;
83
+ weight. saturating_accrue ( T :: DbWeight :: get ( ) . reads ( 1 ) ) ;
84
+
85
+ // Add stake to the pending emissions for the new hotkey and the old hotkey
86
+ PendingdHotkeyEmission :: < T > :: insert (
87
+ new_hotkey,
88
+ pending_emissions_new
89
+ . saturating_add ( pending_emissions_old)
90
+ . saturating_add ( null_stake) ,
91
+ ) ;
76
92
weight. saturating_accrue ( T :: DbWeight :: get ( ) . writes ( 1 ) ) ;
77
93
78
94
weight
0 commit comments