@@ -891,7 +891,7 @@ impl<T: Config> Pallet<T> {
891
891
. into ( ) )
892
892
}
893
893
894
- /// Facilitates user registration of a new subnetwork.
894
+ /// Facilitates user registration of a new subnetwork with subnet identity .
895
895
///
896
896
/// # Args:
897
897
/// * `origin` (`T::RuntimeOrigin`): The calling origin. Must be signed.
@@ -1126,20 +1126,19 @@ impl<T: Config> Pallet<T> {
1126
1126
/// Removes a network (identified by netuid) and all associated parameters.
1127
1127
///
1128
1128
/// This function is responsible for cleaning up all the data associated with a network.
1129
- /// It ensures that all the storage values related to the network are removed, and any
1130
- /// reserved balance is returned to the network owner.
1129
+ /// It ensures that all the storage values related to the network are removed, any
1130
+ /// reserved balance is returned to the network owner, and the subnet identity is removed if it exists .
1131
1131
///
1132
1132
/// # Args:
1133
1133
/// * 'netuid': ('u16'): The unique identifier of the network to be removed.
1134
1134
///
1135
1135
/// # Note:
1136
1136
/// This function does not emit any events, nor does it raise any errors. It silently
1137
1137
/// returns if any internal checks fail.
1138
- ///
1139
1138
pub fn remove_network ( netuid : u16 ) {
1140
1139
// --- 1. Return balance to subnet owner.
1141
- let owner_coldkey = SubnetOwner :: < T > :: get ( netuid) ;
1142
- let reserved_amount = Self :: get_subnet_locked_balance ( netuid) ;
1140
+ let owner_coldkey: T :: AccountId = SubnetOwner :: < T > :: get ( netuid) ;
1141
+ let reserved_amount: u64 = Self :: get_subnet_locked_balance ( netuid) ;
1143
1142
1144
1143
// --- 2. Remove network count.
1145
1144
SubnetworkN :: < T > :: remove ( netuid) ;
@@ -1150,13 +1149,13 @@ impl<T: Config> Pallet<T> {
1150
1149
// --- 4. Remove netuid from added networks.
1151
1150
NetworksAdded :: < T > :: remove ( netuid) ;
1152
1151
1153
- // --- 6 . Decrement the network counter.
1154
- TotalNetworks :: < T > :: mutate ( |n| * n = n. saturating_sub ( 1 ) ) ;
1152
+ // --- 5 . Decrement the network counter.
1153
+ TotalNetworks :: < T > :: mutate ( |n : & mut u16 | * n = n. saturating_sub ( 1 ) ) ;
1155
1154
1156
- // --- 7 . Remove various network-related storages.
1155
+ // --- 6 . Remove various network-related storages.
1157
1156
NetworkRegisteredAt :: < T > :: remove ( netuid) ;
1158
1157
1159
- // --- 8 . Remove incentive mechanism memory.
1158
+ // --- 7 . Remove incentive mechanism memory.
1160
1159
let _ = Uids :: < T > :: clear_prefix ( netuid, u32:: MAX , None ) ;
1161
1160
let _ = Keys :: < T > :: clear_prefix ( netuid, u32:: MAX , None ) ;
1162
1161
let _ = Bonds :: < T > :: clear_prefix ( netuid, u32:: MAX , None ) ;
@@ -1171,7 +1170,7 @@ impl<T: Config> Pallet<T> {
1171
1170
)
1172
1171
{
1173
1172
// Create a new vector to hold modified weights.
1174
- let mut modified_weights = weights_i. clone ( ) ;
1173
+ let mut modified_weights: Vec < ( u16 , u16 ) > = weights_i. clone ( ) ;
1175
1174
// Iterate over each weight entry to potentially update it.
1176
1175
for ( subnet_id, weight) in modified_weights. iter_mut ( ) {
1177
1176
if subnet_id == & netuid {
@@ -1213,6 +1212,12 @@ impl<T: Config> Pallet<T> {
1213
1212
Self :: add_balance_to_coldkey_account ( & owner_coldkey, reserved_amount) ;
1214
1213
Self :: set_subnet_locked_balance ( netuid, 0 ) ;
1215
1214
SubnetOwner :: < T > :: remove ( netuid) ;
1215
+
1216
+ // --- 13. Remove subnet identity if it exists.
1217
+ if SubnetIdentities :: < T > :: contains_key ( netuid) {
1218
+ SubnetIdentities :: < T > :: remove ( netuid) ;
1219
+ Self :: deposit_event ( Event :: SubnetIdentityRemoved ( netuid) ) ;
1220
+ }
1216
1221
}
1217
1222
1218
1223
#[ allow( clippy:: arithmetic_side_effects) ]
0 commit comments