Skip to content

Commit 8f0a7cb

Browse files
committed
add neuron prune impl
1 parent ccb39d7 commit 8f0a7cb

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

pallets/subtensor/src/subnets/registration.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -425,29 +425,11 @@ impl<T: Config> Pallet<T> {
425425
return 0; // If there are no neurons in this network.
426426
}
427427

428-
// Get SN owner top stake hotkey
429-
let mut top_stake_sn_owner_hotkey: Option<T::AccountId> = None;
430-
let mut max_stake_weight: I64F64 = I64F64::from_num(-1);
431428
for neuron_uid in 0..neurons_n {
429+
// Do not deregister the owner's hotkey from the `SubnetOwnerHotkey` map
432430
if let Ok(hotkey) = Self::get_hotkey_for_net_and_uid(netuid, neuron_uid) {
433-
let coldkey = Self::get_owning_coldkey_for_hotkey(&hotkey);
434-
if Self::get_subnet_owner(netuid) != coldkey {
435-
continue;
436-
}
437-
438-
let stake_weights = Self::get_stake_weights_for_hotkey_on_subnet(&hotkey, netuid);
439-
if stake_weights.0 > max_stake_weight {
440-
max_stake_weight = stake_weights.0;
441-
top_stake_sn_owner_hotkey = Some(hotkey);
442-
}
443-
}
444-
}
445-
446-
for neuron_uid in 0..neurons_n {
447-
// Do not deregister the owner's top-stake hotkey
448-
if let Ok(hotkey) = Self::get_hotkey_for_net_and_uid(netuid, neuron_uid) {
449-
if let Some(ref top_sn_owner_hotkey) = top_stake_sn_owner_hotkey {
450-
if top_sn_owner_hotkey == &hotkey {
431+
if let Ok(top_sn_owner_hotkey) = SubnetOwnerHotkey::<T>::try_get(netuid) {
432+
if top_sn_owner_hotkey == hotkey {
451433
continue;
452434
}
453435
}

0 commit comments

Comments
 (0)