@@ -4,7 +4,7 @@ use frame_support::storage::IterableStorageMap;
4
4
extern crate alloc;
5
5
use codec:: Compact ;
6
6
7
- #[ freeze_struct( "ccca539640c3f631 " ) ]
7
+ #[ freeze_struct( "fe79d58173da662a " ) ]
8
8
#[ derive( Decode , Encode , PartialEq , Eq , Clone , Debug ) ]
9
9
pub struct SubnetInfo < T : Config > {
10
10
netuid : Compact < u16 > ,
@@ -25,6 +25,29 @@ pub struct SubnetInfo<T: Config> {
25
25
emission_values : Compact < u64 > ,
26
26
burn : Compact < u64 > ,
27
27
owner : T :: AccountId ,
28
+ }
29
+
30
+ #[ freeze_struct( "65f931972fa13222" ) ]
31
+ #[ derive( Decode , Encode , PartialEq , Eq , Clone , Debug ) ]
32
+ pub struct SubnetInfov2 < T : Config > {
33
+ netuid : Compact < u16 > ,
34
+ rho : Compact < u16 > ,
35
+ kappa : Compact < u16 > ,
36
+ difficulty : Compact < u64 > ,
37
+ immunity_period : Compact < u16 > ,
38
+ max_allowed_validators : Compact < u16 > ,
39
+ min_allowed_weights : Compact < u16 > ,
40
+ max_weights_limit : Compact < u16 > ,
41
+ scaling_law_power : Compact < u16 > ,
42
+ subnetwork_n : Compact < u16 > ,
43
+ max_allowed_uids : Compact < u16 > ,
44
+ blocks_since_last_step : Compact < u64 > ,
45
+ tempo : Compact < u16 > ,
46
+ network_modality : Compact < u16 > ,
47
+ network_connect : Vec < [ u16 ; 2 ] > ,
48
+ emission_values : Compact < u64 > ,
49
+ burn : Compact < u64 > ,
50
+ owner : T :: AccountId ,
28
51
identity : Option < SubnetIdentity > ,
29
52
}
30
53
@@ -81,8 +104,6 @@ impl<T: Config> Pallet<T> {
81
104
let network_modality = <NetworkModality < T > >:: get ( netuid) ;
82
105
let emission_values = Self :: get_emission_value ( netuid) ;
83
106
let burn: Compact < u64 > = Self :: get_burn_as_u64 ( netuid) . into ( ) ;
84
- let identity: Option < SubnetIdentity > = SubnetIdentities :: < T > :: get ( netuid) ;
85
-
86
107
// DEPRECATED
87
108
let network_connect: Vec < [ u16 ; 2 ] > = Vec :: < [ u16 ; 2 ] > :: new ( ) ;
88
109
// DEPRECATED for ( _netuid_, con_req) in < NetworkConnect<T> as IterableStorageDoubleMap<u16, u16, u16> >::iter_prefix(netuid) {
@@ -108,7 +129,6 @@ impl<T: Config> Pallet<T> {
108
129
emission_values : emission_values. into ( ) ,
109
130
burn,
110
131
owner : Self :: get_subnet_owner ( netuid) ,
111
- identity,
112
132
} )
113
133
}
114
134
@@ -134,6 +154,77 @@ impl<T: Config> Pallet<T> {
134
154
subnets_info
135
155
}
136
156
157
+ pub fn get_subnet_info_v2 ( netuid : u16 ) -> Option < SubnetInfov2 < T > > {
158
+ if !Self :: if_subnet_exist ( netuid) {
159
+ return None ;
160
+ }
161
+
162
+ let rho = Self :: get_rho ( netuid) ;
163
+ let kappa = Self :: get_kappa ( netuid) ;
164
+ let difficulty: Compact < u64 > = Self :: get_difficulty_as_u64 ( netuid) . into ( ) ;
165
+ let immunity_period = Self :: get_immunity_period ( netuid) ;
166
+ let max_allowed_validators = Self :: get_max_allowed_validators ( netuid) ;
167
+ let min_allowed_weights = Self :: get_min_allowed_weights ( netuid) ;
168
+ let max_weights_limit = Self :: get_max_weight_limit ( netuid) ;
169
+ let scaling_law_power = Self :: get_scaling_law_power ( netuid) ;
170
+ let subnetwork_n = Self :: get_subnetwork_n ( netuid) ;
171
+ let max_allowed_uids = Self :: get_max_allowed_uids ( netuid) ;
172
+ let blocks_since_last_step = Self :: get_blocks_since_last_step ( netuid) ;
173
+ let tempo = Self :: get_tempo ( netuid) ;
174
+ let network_modality = <NetworkModality < T > >:: get ( netuid) ;
175
+ let emission_values = Self :: get_emission_value ( netuid) ;
176
+ let burn: Compact < u64 > = Self :: get_burn_as_u64 ( netuid) . into ( ) ;
177
+ let identity: Option < SubnetIdentity > = SubnetIdentities :: < T > :: get ( netuid) ;
178
+
179
+ // DEPRECATED
180
+ let network_connect: Vec < [ u16 ; 2 ] > = Vec :: < [ u16 ; 2 ] > :: new ( ) ;
181
+ // DEPRECATED for ( _netuid_, con_req) in < NetworkConnect<T> as IterableStorageDoubleMap<u16, u16, u16> >::iter_prefix(netuid) {
182
+ // network_connect.push([_netuid_, con_req]);
183
+ // }
184
+
185
+ Some ( SubnetInfov2 {
186
+ rho : rho. into ( ) ,
187
+ kappa : kappa. into ( ) ,
188
+ difficulty,
189
+ immunity_period : immunity_period. into ( ) ,
190
+ netuid : netuid. into ( ) ,
191
+ max_allowed_validators : max_allowed_validators. into ( ) ,
192
+ min_allowed_weights : min_allowed_weights. into ( ) ,
193
+ max_weights_limit : max_weights_limit. into ( ) ,
194
+ scaling_law_power : scaling_law_power. into ( ) ,
195
+ subnetwork_n : subnetwork_n. into ( ) ,
196
+ max_allowed_uids : max_allowed_uids. into ( ) ,
197
+ blocks_since_last_step : blocks_since_last_step. into ( ) ,
198
+ tempo : tempo. into ( ) ,
199
+ network_modality : network_modality. into ( ) ,
200
+ network_connect,
201
+ emission_values : emission_values. into ( ) ,
202
+ burn,
203
+ owner : Self :: get_subnet_owner ( netuid) ,
204
+ identity,
205
+ } )
206
+ }
207
+ pub fn get_subnets_info_v2 ( ) -> Vec < Option < SubnetInfo < T > > > {
208
+ let mut subnet_netuids = Vec :: < u16 > :: new ( ) ;
209
+ let mut max_netuid: u16 = 0 ;
210
+ for ( netuid, added) in <NetworksAdded < T > as IterableStorageMap < u16 , bool > >:: iter ( ) {
211
+ if added {
212
+ subnet_netuids. push ( netuid) ;
213
+ if netuid > max_netuid {
214
+ max_netuid = netuid;
215
+ }
216
+ }
217
+ }
218
+
219
+ let mut subnets_info = Vec :: < Option < SubnetInfo < T > > > :: new ( ) ;
220
+ for netuid_ in 0 ..=max_netuid {
221
+ if subnet_netuids. contains ( & netuid_) {
222
+ subnets_info. push ( Self :: get_subnet_info ( netuid_) ) ;
223
+ }
224
+ }
225
+
226
+ subnets_info
227
+ }
137
228
pub fn get_subnet_hyperparams ( netuid : u16 ) -> Option < SubnetHyperparams > {
138
229
if !Self :: if_subnet_exist ( netuid) {
139
230
return None ;
0 commit comments