Skip to content

Commit e9b0051

Browse files
committed
add swap hotkey impl
1 parent 8f0a7cb commit e9b0051

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pallets/subtensor/src/swap/swap_hotkey.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,18 @@ impl<T: Config> Pallet<T> {
437437
}
438438
}
439439

440+
// 15. Swap SubnetOwnerHotkey
441+
// SubnetOwnerHotkey( netuid ) --> hotkey -- the hotkey that is the owner of the subnet.
442+
for netuid in Self::get_all_subnet_netuids() {
443+
if let Ok(old_subnet_owner_hotkey) = SubnetOwnerHotkey::<T>::try_get(netuid) {
444+
weight.saturating_accrue(T::DbWeight::get().reads(1));
445+
if old_subnet_owner_hotkey == *old_hotkey {
446+
SubnetOwnerHotkey::<T>::insert(netuid, new_hotkey);
447+
weight.saturating_accrue(T::DbWeight::get().writes(1));
448+
}
449+
}
450+
}
451+
440452
// Return successful after swapping all the relevant terms.
441453
Ok(())
442454
}

0 commit comments

Comments
 (0)