@@ -115,19 +115,19 @@ def __init__(
115
115
network : Optional [str ] = None ,
116
116
config : Optional ["Config" ] = None ,
117
117
log_verbose : bool = False ,
118
- fallback_chains : Optional [list [str ]] = None ,
118
+ fallback_endpoints : Optional [list [str ]] = None ,
119
119
retry_forever : bool = False ,
120
120
_mock : bool = False ,
121
121
):
122
122
"""
123
123
Initializes an instance of the AsyncSubtensor class.
124
124
125
125
Arguments:
126
- network (str) : The network name or type to connect to.
127
- config (Optional[Config]) : Configuration object for the AsyncSubtensor instance.
128
- log_verbose (bool) : Enables or disables verbose logging.
129
- fallback_chains (list) : List of fallback chains endpoints to use if no network is specified . Defaults to `None`.
130
- retry_forever (bool) : Whether to retry forever on connection errors. Defaults to `False`.
126
+ network: The network name or type to connect to.
127
+ config: Configuration object for the AsyncSubtensor instance.
128
+ log_verbose: Enables or disables verbose logging.
129
+ fallback_endpoints : List of fallback endpoints to use if default or provided network is not available . Defaults to `None`.
130
+ retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
131
131
_mock: Whether this is a mock instance. Mainly just for use in testing.
132
132
133
133
Raises:
@@ -148,7 +148,9 @@ def __init__(
148
148
f"chain_endpoint: [blue]{ self .chain_endpoint } [/blue]..."
149
149
)
150
150
self .substrate = self ._get_substrate (
151
- fallback_chains = fallback_chains , retry_forever = retry_forever , _mock = _mock
151
+ fallback_endpoints = fallback_endpoints ,
152
+ retry_forever = retry_forever ,
153
+ _mock = _mock ,
152
154
)
153
155
if self .log_verbose :
154
156
logging .info (
@@ -284,24 +286,24 @@ async def get_hyperparameter(
284
286
285
287
def _get_substrate (
286
288
self ,
287
- fallback_chains : Optional [list [str ]] = None ,
289
+ fallback_endpoints : Optional [list [str ]] = None ,
288
290
retry_forever : bool = False ,
289
291
_mock : bool = False ,
290
292
) -> Union [AsyncSubstrateInterface , RetryAsyncSubstrate ]:
291
293
"""Creates the Substrate instance based on provided arguments.
292
294
293
295
Arguments:
294
- fallback_chains (list) : List of fallback chains endpoints to use if no network is specified . Defaults to `None`.
295
- retry_forever (bool) : Whether to retry forever on connection errors. Defaults to `False`.
296
+ fallback_endpoints : List of fallback endpoints to use if default or provided network is not available . Defaults to `None`.
297
+ retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
296
298
_mock: Whether this is a mock instance. Mainly just for use in testing.
297
299
298
300
Returns:
299
301
the instance of the SubstrateInterface or RetrySyncSubstrate class.
300
302
"""
301
- if fallback_chains or retry_forever :
303
+ if fallback_endpoints or retry_forever :
302
304
return RetryAsyncSubstrate (
303
305
url = self .chain_endpoint ,
304
- fallback_chains = fallback_chains ,
306
+ fallback_chains = fallback_endpoints ,
305
307
ss58_format = SS58_FORMAT ,
306
308
type_registry = TYPE_REGISTRY ,
307
309
retry_forever = retry_forever ,
@@ -2582,6 +2584,35 @@ async def is_hotkey_registered_on_subnet(
2582
2584
is not None
2583
2585
)
2584
2586
2587
+ async def is_subnet_active (
2588
+ self ,
2589
+ netuid : int ,
2590
+ block : Optional [int ] = None ,
2591
+ block_hash : Optional [str ] = None ,
2592
+ reuse_block : bool = False ,
2593
+ ) -> bool :
2594
+ """Verify if subnet with provided netuid is active.
2595
+
2596
+ Args:
2597
+ netuid (int): The unique identifier of the subnet.
2598
+ block (Optional[int]): The blockchain block number for the query.
2599
+ block_hash (Optional[str]): The blockchain block_hash representation of block id.
2600
+ reuse_block (bool): Whether to reuse the last-used block hash.
2601
+
2602
+ Returns:
2603
+ True if subnet is active, False otherwise.
2604
+
2605
+ This means whether the `start_call` was initiated or not.
2606
+ """
2607
+ query = await self .query_subtensor (
2608
+ name = "FirstEmissionBlockNumber" ,
2609
+ block = block ,
2610
+ block_hash = block_hash ,
2611
+ reuse_block = reuse_block ,
2612
+ params = [netuid ],
2613
+ )
2614
+ return True if query and query .value > 0 else False
2615
+
2585
2616
async def last_drand_round (self ) -> Optional [int ]:
2586
2617
"""
2587
2618
Retrieves the last drand round emitted in bittensor. This corresponds when committed weights will be revealed.
0 commit comments