@@ -120,6 +120,8 @@ def __init__(
120
120
fallback_endpoints : Optional [list [str ]] = None ,
121
121
retry_forever : bool = False ,
122
122
_mock : bool = False ,
123
+ archive_endpoints : Optional [list [str ]] = None ,
124
+ websocket_shutdown_timer : float = 5.0 ,
123
125
):
124
126
"""
125
127
Initializes an instance of the AsyncSubtensor class.
@@ -132,6 +134,9 @@ def __init__(
132
134
Defaults to `None`.
133
135
retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
134
136
_mock: Whether this is a mock instance. Mainly just for use in testing.
137
+ archive_endpoints: Similar to fallback_endpoints, but specifically only archive nodes. Will be used in cases
138
+ where you are requesting a block that is too old for your current (presumably lite) node. Defaults to
139
+ `None`
135
140
136
141
Raises:
137
142
Any exceptions raised during the setup, configuration, or connection process.
@@ -154,6 +159,8 @@ def __init__(
154
159
fallback_endpoints = fallback_endpoints ,
155
160
retry_forever = retry_forever ,
156
161
_mock = _mock ,
162
+ archive_endpoints = archive_endpoints ,
163
+ ws_shutdown_timer = websocket_shutdown_timer ,
157
164
)
158
165
if self .log_verbose :
159
166
logging .info (
@@ -292,6 +299,8 @@ def _get_substrate(
292
299
fallback_endpoints : Optional [list [str ]] = None ,
293
300
retry_forever : bool = False ,
294
301
_mock : bool = False ,
302
+ archive_endpoints : Optional [list [str ]] = None ,
303
+ ws_shutdown_timer : float = 5.0 ,
295
304
) -> Union [AsyncSubstrateInterface , RetryAsyncSubstrate ]:
296
305
"""Creates the Substrate instance based on provided arguments.
297
306
@@ -300,11 +309,16 @@ def _get_substrate(
300
309
Defaults to `None`.
301
310
retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
302
311
_mock: Whether this is a mock instance. Mainly just for use in testing.
312
+ archive_endpoints: Similar to fallback_endpoints, but specifically only archive nodes. Will be used in cases
313
+ where you are requesting a block that is too old for your current (presumably lite) node. Defaults to
314
+ `None`
315
+ ws_shutdown_timer: Amount of time, in seconds, to wait after the last response from the chain to close the
316
+ connection.
303
317
304
318
Returns:
305
319
the instance of the SubstrateInterface or RetrySyncSubstrate class.
306
320
"""
307
- if fallback_endpoints or retry_forever :
321
+ if fallback_endpoints or retry_forever or archive_endpoints :
308
322
return RetryAsyncSubstrate (
309
323
url = self .chain_endpoint ,
310
324
fallback_chains = fallback_endpoints ,
@@ -314,6 +328,8 @@ def _get_substrate(
314
328
use_remote_preset = True ,
315
329
chain_name = "Bittensor" ,
316
330
_mock = _mock ,
331
+ archive_nodes = archive_endpoints ,
332
+ ws_shutdown_timer = ws_shutdown_timer ,
317
333
)
318
334
return AsyncSubstrateInterface (
319
335
url = self .chain_endpoint ,
@@ -322,6 +338,7 @@ def _get_substrate(
322
338
use_remote_preset = True ,
323
339
chain_name = "Bittensor" ,
324
340
_mock = _mock ,
341
+ ws_shutdown_timer = ws_shutdown_timer ,
325
342
)
326
343
327
344
# Subtensor queries ===========================================================================================
0 commit comments