Skip to content

Commit 418f104

Browse files
author
Roman
committed
move withing module
1 parent 2481087 commit 418f104

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

bittensor/core/subtensor.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,40 @@ def add_args(cls, parser: "argparse.ArgumentParser", prefix: Optional[str] = Non
412412
# re-parsing arguments.
413413
pass
414414

415+
@staticmethod
416+
def determine_chain_endpoint_and_network(
417+
network: str,
418+
) -> tuple[Optional[str], Optional[str]]:
419+
"""Determines the chain endpoint and network from the passed network or chain_endpoint.
420+
421+
Args:
422+
network (str): The network flag. The choices are: ``finney`` (main network), ``archive`` (archive network +300 blocks), ``local`` (local running network), ``test`` (test network).
423+
424+
Returns:
425+
tuple[Optional[str], Optional[str]]: The network and chain endpoint flag. If passed, overrides the ``network`` argument.
426+
"""
427+
428+
if network is None:
429+
return None, None
430+
if network in settings.NETWORKS:
431+
return network, settings.NETWORK_MAP[network]
432+
433+
substrings_map = {
434+
"entrypoint-finney.opentensor.ai": ("finney", settings.FINNEY_ENTRYPOINT),
435+
"test.finney.opentensor.ai": ("test", settings.FINNEY_TEST_ENTRYPOINT),
436+
"archive.chain.opentensor.ai": ("archive", settings.ARCHIVE_ENTRYPOINT),
437+
"subvortex": ("subvortex", network),
438+
"subvortex.info": ("subvortex", network),
439+
"127.0.0.1": ("local", network),
440+
"localhost": ("local", network),
441+
}
442+
443+
for substring, result in substrings_map.items():
444+
if substring in network:
445+
return result
446+
447+
return "unknown", network
448+
415449
# Inner private functions
416450
@networking.ensure_connected
417451
def _encode_params(
@@ -709,40 +743,6 @@ def metagraph(
709743

710744
return metagraph
711745

712-
@staticmethod
713-
def determine_chain_endpoint_and_network(
714-
network: str,
715-
) -> tuple[Optional[str], Optional[str]]:
716-
"""Determines the chain endpoint and network from the passed network or chain_endpoint.
717-
718-
Args:
719-
network (str): The network flag. The choices are: ``finney`` (main network), ``archive`` (archive network +300 blocks), ``local`` (local running network), ``test`` (test network).
720-
721-
Returns:
722-
tuple[Optional[str], Optional[str]]: The network and chain endpoint flag. If passed, overrides the ``network`` argument.
723-
"""
724-
725-
if network is None:
726-
return None, None
727-
if network in settings.NETWORKS:
728-
return network, settings.NETWORK_MAP[network]
729-
730-
substrings_map = {
731-
"entrypoint-finney.opentensor.ai": ("finney", settings.FINNEY_ENTRYPOINT),
732-
"test.finney.opentensor.ai": ("test", settings.FINNEY_TEST_ENTRYPOINT),
733-
"archive.chain.opentensor.ai": ("archive", settings.ARCHIVE_ENTRYPOINT),
734-
"subvortex": ("subvortex", network),
735-
"subvortex.info": ("subvortex", network),
736-
"127.0.0.1": ("local", network),
737-
"localhost": ("local", network),
738-
}
739-
740-
for substring, result in substrings_map.items():
741-
if substring in network:
742-
return result
743-
744-
return "unknown", network
745-
746746
def get_netuids_for_hotkey(
747747
self, hotkey_ss58: str, block: Optional[int] = None
748748
) -> list[int]:

0 commit comments

Comments
 (0)