Skip to content

Commit fa41075

Browse files
committed
- Use match instead
1 parent 270f0a0 commit fa41075

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

pallets/subtensor/src/swap/swap_hotkey.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,21 @@ impl<T: Config> Pallet<T> {
5757

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

60-
// 7. Ensure the new hotkey is not already registered on any network, only if netuid is none
61-
if netuid.is_none() {
62-
ensure!(
63-
!Self::is_hotkey_registered_on_any_network(new_hotkey),
64-
Error::<T>::HotKeyAlreadyRegisteredInSubNet
65-
);
66-
}
67-
68-
// 7.1. Ensure the hotkey is not registered on the network before, if netuid is provided
69-
if let Some(netuid) = netuid {
70-
ensure!(
71-
!Self::is_hotkey_registered_on_specific_network(new_hotkey, netuid),
72-
Error::<T>::HotKeyAlreadyRegisteredInSubNet
73-
);
60+
match netuid {
61+
// 7. Ensure the hotkey is not registered on the network before, if netuid is provided
62+
Some(netuid) => {
63+
ensure!(
64+
!Self::is_hotkey_registered_on_specific_network(new_hotkey, netuid),
65+
Error::<T>::HotKeyAlreadyRegisteredInSubNet
66+
);
67+
}
68+
// 7.1 Ensure the new hotkey is not already registered on any network, only if netuid is none
69+
None => {
70+
ensure!(
71+
!Self::is_hotkey_registered_on_any_network(new_hotkey),
72+
Error::<T>::HotKeyAlreadyRegisteredInSubNet
73+
);
74+
}
7475
}
7576

7677
// 8. Swap LastTxBlock

0 commit comments

Comments
 (0)