@@ -9,6 +9,37 @@ impl<T: Config> Pallet<T> {
9
9
SubnetworkN :: < T > :: get ( netuid)
10
10
}
11
11
12
+ pub fn set_emission_for_uid ( netuid : u16 , neuron_uid : u16 , emission : u64 ) {
13
+ Emission :: < T > :: mutate ( netuid, |v| v[ neuron_uid as usize ] = emission) ;
14
+ }
15
+ pub fn set_trust_for_uid ( netuid : u16 , neuron_uid : u16 , trust : u16 ) {
16
+ Trust :: < T > :: mutate ( netuid, |v| v[ neuron_uid as usize ] = trust) ;
17
+ }
18
+ pub fn set_consensus_for_uid ( netuid : u16 , neuron_uid : u16 , consensus : u16 ) {
19
+ Consensus :: < T > :: mutate ( netuid, |v| v[ neuron_uid as usize ] = consensus) ;
20
+ }
21
+ pub fn set_incentive_for_uid ( netuid : u16 , neuron_uid : u16 , incentive : u16 ) {
22
+ Incentive :: < T > :: mutate ( netuid, |v| v[ neuron_uid as usize ] = incentive) ;
23
+ }
24
+ pub fn set_dividends_for_uid ( netuid : u16 , neuron_uid : u16 , dividends : u16 ) {
25
+ Dividends :: < T > :: mutate ( netuid, |v| v[ neuron_uid as usize ] = dividends) ;
26
+ }
27
+
28
+ fn reset_axon_info_for_uid ( netuid : u16 , old_hotkey : & T :: AccountId , new_hotkey : & T :: AccountId ) {
29
+ let axon_info = AxonInfo {
30
+ block : 0 ,
31
+ version : 0 ,
32
+ ip : 0 ,
33
+ port : 0 ,
34
+ ip_type : 0 ,
35
+ protocol : 0 ,
36
+ placeholder1 : 0 ,
37
+ placeholder2 : 0 ,
38
+ } ;
39
+ Axons :: < T > :: remove ( netuid, old_hotkey) ;
40
+ Axons :: < T > :: set ( netuid, new_hotkey, Some ( axon_info) ) ;
41
+ }
42
+
12
43
/// Replace the neuron under this uid.
13
44
pub fn replace_neuron (
14
45
netuid : u16 ,
@@ -45,6 +76,15 @@ impl<T: Config> Pallet<T> {
45
76
Uids :: < T > :: insert ( netuid, new_hotkey. clone ( ) , uid_to_replace) ; // Make uid - hotkey association.
46
77
BlockAtRegistration :: < T > :: insert ( netuid, uid_to_replace, block_number) ; // Fill block at registration.
47
78
IsNetworkMember :: < T > :: insert ( new_hotkey. clone ( ) , netuid, true ) ; // Fill network is member.
79
+
80
+ // 4. Reset trust, emission, consensus, incentive, dividends and axon_info for the new uid.
81
+ Self :: set_trust_for_uid ( netuid, uid_to_replace, 0 ) ;
82
+ Self :: set_emission_for_uid ( netuid, uid_to_replace, 0 ) ;
83
+ Self :: set_consensus_for_uid ( netuid, uid_to_replace, 0 ) ;
84
+ Self :: set_incentive_for_uid ( netuid, uid_to_replace, 0 ) ;
85
+ Self :: set_dividends_for_uid ( netuid, uid_to_replace, 0 ) ;
86
+
87
+ Self :: reset_axon_info_for_uid ( netuid, & old_hotkey, new_hotkey) ;
48
88
}
49
89
50
90
/// Appends the uid to the network.
0 commit comments