Skip to content

Commit

Permalink
Introduce block_hash and reuse_block args for is_hotkey_registered.
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhaleking committed Jan 7, 2025
1 parent cf5dd72 commit 85c294a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,8 @@ async def is_hotkey_registered(
hotkey_ss58: str,
netuid: Optional[int] = None,
block: Optional[int] = None,
block_hash: Optional[str] = None,
reuse_block: bool = False,
) -> bool:
"""
Determines whether a given hotkey (public key) is registered in the Bittensor network, either globally across
Expand All @@ -1626,10 +1628,14 @@ async def is_hotkey_registered(
network.
Args:
hotkey_ss58 (str): The SS58 address of the neuron's hotkey.
netuid (Optional[int]): The unique identifier of the subnet to check the registration. If `None`, the
hotkey_ss58: The SS58 address of the neuron's hotkey.
netuid: The unique identifier of the subnet to check the registration. If `None`, the
registration is checked across all subnets.
block (Optional[int]): The blockchain block number at which to perform the query.
block: The blockchain block number at which to perform the query.
block_hash: The blockchain block_hash representation of the block id. Do not specify if using block or
reuse_block
reuse_block (bool): Whether to reuse the last-used blockchain block hash. Do not set if using block_hash or
reuse_block.
Returns:
bool: `True` if the hotkey is registered in the specified context (either any subnet or a specific subnet),
Expand All @@ -1640,9 +1646,13 @@ async def is_hotkey_registered(
validation, and incentive distribution based on its registration status.
"""
if netuid is None:
return await self.is_hotkey_registered_any(hotkey_ss58, block)
return await self.is_hotkey_registered_any(
hotkey_ss58, block, block_hash, reuse_block
)
else:
return await self.is_hotkey_registered_on_subnet(hotkey_ss58, netuid, block)
return await self.is_hotkey_registered_on_subnet(
hotkey_ss58, netuid, block, block_hash, reuse_block
)

async def get_uid_for_hotkey_on_subnet(
self,
Expand Down

0 comments on commit 85c294a

Please sign in to comment.