Skip to content

Commit b470d78

Browse files
author
Roman
committed
update docstrings, fix bug
1 parent 329ce85 commit b470d78

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

bittensor/core/async_subtensor.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __init__(
127127
network (str): The network name or type to connect to.
128128
config (Optional[Config]): Configuration object for the AsyncSubtensor instance.
129129
log_verbose (bool): Enables or disables verbose logging.
130-
fallback_chains (list): List of fallback chains to use if no network is specified. Defaults to `None`.
130+
fallback_chains (list): List of fallback chains endpoints to use if no network is specified. Defaults to `None`.
131131
retry_forever (bool): Whether to retry forever on connection errors. Defaults to `False`.
132132
_mock: Whether this is a mock instance. Mainly just for use in testing.
133133
@@ -148,14 +148,6 @@ def __init__(
148148
f"Connecting to network: [blue]{self.network}[/blue], "
149149
f"chain_endpoint: [blue]{self.chain_endpoint}[/blue]..."
150150
)
151-
self.substrate = AsyncSubstrateInterface(
152-
url=self.chain_endpoint,
153-
ss58_format=SS58_FORMAT,
154-
type_registry=TYPE_REGISTRY,
155-
use_remote_preset=True,
156-
chain_name="Bittensor",
157-
_mock=_mock,
158-
)
159151
self.substrate = self._get_substrate(
160152
fallback_chains=fallback_chains, retry_forever=retry_forever, _mock=_mock
161153
)
@@ -300,7 +292,7 @@ def _get_substrate(
300292
"""Creates the Substrate instance based on provided arguments.
301293
302294
Arguments:
303-
fallback_chains (list): List of fallback chains to use if no network is specified. Defaults to `None`.
295+
fallback_chains (list): List of fallback chains endpoints to use if no network is specified. Defaults to `None`.
304296
retry_forever (bool): Whether to retry forever on connection errors. Defaults to `False`.
305297
_mock: Whether this is a mock instance. Mainly just for use in testing.
306298

bittensor/core/subtensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def __init__(
129129
network (str): The network name or type to connect to.
130130
config (Optional[Config]): Configuration object for the AsyncSubtensor instance.
131131
log_verbose (bool): Enables or disables verbose logging.
132-
fallback_chains (list): List of fallback chains to use if no network is specified. Defaults to `None`.
132+
fallback_chains (list): List of fallback chains endpoints to use if no network is specified. Defaults to `None`.
133133
retry_forever (bool): Whether to retry forever on connection errors. Defaults to `False`.
134134
_mock: Whether this is a mock instance. Mainly just for use in testing.
135135
@@ -175,7 +175,7 @@ def _get_substrate(
175175
"""Creates the Substrate instance based on provided arguments.
176176
177177
Arguments:
178-
fallback_chains (list): List of fallback chains to use if no network is specified. Defaults to `None`.
178+
fallback_chains (list): List of fallback chains endpoints to use if no network is specified. Defaults to `None`.
179179
retry_forever (bool): Whether to retry forever on connection errors. Defaults to `False`.
180180
_mock: Whether this is a mock instance. Mainly just for use in testing.
181181

bittensor/core/subtensor_api/__init__.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ class SubtensorApi:
5353
5454
subtensor = bt.SubtensorApi(legacy_methods=True)
5555
print(subtensor.bonds(0))
56+
57+
# using `fallback_chains` or `retry_forever`
58+
import bittensor as bt
59+
60+
5661
"""
5762

5863
def __init__(
@@ -123,6 +128,12 @@ def _get_subtensor(self) -> Union["_Subtensor", "_AsyncSubtensor"]:
123128
_mock=self._mock,
124129
)
125130

131+
def _determine_chain_endpoint(self) -> str:
132+
"""Determines the connection and mock flag."""
133+
if self._mock:
134+
return "Mock"
135+
return self.substrate.url
136+
126137
def __str__(self):
127138
return (
128139
f"<Network: {self.network}, "
@@ -145,12 +156,6 @@ async def __aenter__(self):
145156
async def __aexit__(self, exc_type, exc_val, exc_tb):
146157
await self.substrate.close()
147158

148-
def _determine_chain_endpoint(self) -> str:
149-
"""Determines the connection and mock flag."""
150-
if self._mock:
151-
return "Mock"
152-
return self.substrate.url
153-
154159
@property
155160
def block(self):
156161
"""Returns current chain block number."""

0 commit comments

Comments
 (0)