File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -2582,6 +2582,35 @@ async def is_hotkey_registered_on_subnet(
2582
2582
is not None
2583
2583
)
2584
2584
2585
+ async def is_subnet_active (
2586
+ self ,
2587
+ netuid : int ,
2588
+ block : Optional [int ] = None ,
2589
+ block_hash : Optional [str ] = None ,
2590
+ reuse_block : bool = False ,
2591
+ ) -> bool :
2592
+ """Verify if subnet with provided netuid is active.
2593
+
2594
+ Args:
2595
+ netuid (int): The unique identifier of the subnet.
2596
+ block (Optional[int]): The blockchain block number for the query.
2597
+ block_hash (Optional[str]): The blockchain block_hash representation of block id.
2598
+ reuse_block (bool): Whether to reuse the last-used block hash.
2599
+
2600
+ Returns:
2601
+ True if subnet is active, False otherwise.
2602
+
2603
+ This means whether the `start_call` was initiated or not.
2604
+ """
2605
+ query = await self .query_subtensor (
2606
+ name = "FirstEmissionBlockNumber" ,
2607
+ block = block ,
2608
+ block_hash = block_hash ,
2609
+ reuse_block = reuse_block ,
2610
+ params = [netuid ],
2611
+ )
2612
+ return True if query and query .value > 0 else False
2613
+
2585
2614
async def last_drand_round (self ) -> Optional [int ]:
2586
2615
"""
2587
2616
Retrieves the last drand round emitted in bittensor. This corresponds when committed weights will be revealed.
Original file line number Diff line number Diff line change @@ -2023,6 +2023,25 @@ def is_hotkey_registered_on_subnet(
2023
2023
is not None
2024
2024
)
2025
2025
2026
+ def is_subnet_active (self , netuid : int , block : Optional [int ] = None ) -> bool :
2027
+ """Verify if subnet with provided netuid is active.
2028
+
2029
+ Args:
2030
+ netuid (int): The unique identifier of the subnet.
2031
+ block (Optional[int]): The blockchain block number for the query.
2032
+
2033
+ Returns:
2034
+ True if subnet is active, False otherwise.
2035
+
2036
+ This means whether the `start_call` was initiated or not.
2037
+ """
2038
+ query = self .query_subtensor (
2039
+ name = "FirstEmissionBlockNumber" ,
2040
+ block = block ,
2041
+ params = [netuid ],
2042
+ )
2043
+ return True if query and query .value > 0 else False
2044
+
2026
2045
def last_drand_round (self ) -> Optional [int ]:
2027
2046
"""
2028
2047
Retrieves the last drand round emitted in bittensor. This corresponds when committed weights will be revealed.
You can’t perform that action at this time.
0 commit comments