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