Skip to content

Commit 3497cd6

Browse files
author
Roman
committed
add uid check before processing
1 parent 832aff3 commit 3497cd6

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

bittensor/core/async_subtensor.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,9 +1599,15 @@ async def set_weights(
15991599
"""
16001600
retries = 0
16011601
success = False
1602-
uid = await self.get_uid_for_hotkey_on_subnet(
1603-
wallet.hotkey.ss58_address, netuid
1604-
)
1602+
if (
1603+
uid := await self.get_uid_for_hotkey_on_subnet(
1604+
wallet.hotkey.ss58_address, netuid
1605+
)
1606+
) is None:
1607+
return (
1608+
False,
1609+
f"Hotkey {wallet.hotkey.ss58_address} not registered in subnet {netuid}",
1610+
)
16051611

16061612
if (await self.commit_reveal_enabled(netuid=netuid)) is True:
16071613
# go with `commit reveal v3` extrinsic

bittensor/core/subtensor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,13 @@ def set_weights(
18361836
"""
18371837
retries = 0
18381838
success = False
1839-
uid = self.get_uid_for_hotkey_on_subnet(wallet.hotkey.ss58_address, netuid)
1839+
if (
1840+
uid := self.get_uid_for_hotkey_on_subnet(wallet.hotkey.ss58_address, netuid)
1841+
) is None:
1842+
return (
1843+
False,
1844+
f"Hotkey {wallet.hotkey.ss58_address} not registered in subnet {netuid}",
1845+
)
18401846

18411847
if self.commit_reveal_enabled(netuid=netuid) is True:
18421848
# go with `commit reveal v3` extrinsic

0 commit comments

Comments
 (0)