From 85c294aebd3c0986854c44bca6cd52ca02b8074b Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Tue, 7 Jan 2025 20:56:52 +0200 Subject: [PATCH] Introduce block_hash and reuse_block args for is_hotkey_registered. --- bittensor/core/async_subtensor.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/bittensor/core/async_subtensor.py b/bittensor/core/async_subtensor.py index 31d48ecd9e..56d1641ca1 100644 --- a/bittensor/core/async_subtensor.py +++ b/bittensor/core/async_subtensor.py @@ -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 @@ -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), @@ -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,