Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions pallets/subtensor/src/swap/swap_hotkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ impl<T: Config> Pallet<T> {

weight.saturating_accrue(T::DbWeight::get().reads(2));

// 7. Ensure the new hotkey is not already registered on any network
ensure!(
!Self::is_hotkey_registered_on_any_network(new_hotkey),
Error::<T>::HotKeyAlreadyRegisteredInSubNet
);
// 7. Ensure the new hotkey is not already registered on any network, only if netuid is none
if netuid.is_none() {
ensure!(
!Self::is_hotkey_registered_on_any_network(new_hotkey),
Error::<T>::HotKeyAlreadyRegisteredInSubNet
);
}

// 7.1. Ensure the hotkey is not registered on the network before, if netuid is provided
if let Some(netuid) = netuid {
ensure!(
!Self::is_hotkey_registered_on_specific_network(new_hotkey, netuid),
Error::<T>::HotKeyAlreadyRegisteredInSubNet
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to add is_hotkey_registered_on_specific_network check if netuid == Some(netuid).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added additional check, like you suggested here: 893bfb0


// 8. Swap LastTxBlock
let last_tx_block: u64 = Self::get_last_tx_block(old_hotkey);
Expand Down
Loading
Loading