Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions bittensor_cli/src/bittensor/subtensor_interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import os
from typing import Optional, Any, Union, TypedDict, Iterable

import aiohttp
Expand All @@ -9,7 +10,10 @@
import typer


from async_substrate_interface.async_substrate import AsyncSubstrateInterface
from async_substrate_interface.async_substrate import (
DiskCachedAsyncSubstrateInterface,
AsyncSubstrateInterface,
)
from bittensor_cli.src.bittensor.chain_data import (
DelegateInfo,
StakeInfo,
Expand All @@ -34,6 +38,12 @@
u16_normalized_float,
)

SubstrateClass = (
DiskCachedAsyncSubstrateInterface
if os.getenv("DISK_CACHE", "0") == "1"
else AsyncSubstrateInterface
)


class ParamWithTypes(TypedDict):
name: str # Name of the parameter.
Expand Down Expand Up @@ -98,7 +108,7 @@ def __init__(self, network):
self.chain_endpoint = Constants.network_map[defaults.subtensor.network]
self.network = defaults.subtensor.network

self.substrate = AsyncSubstrateInterface(
self.substrate = SubstrateClass(
url=self.chain_endpoint,
ss58_format=SS58_FORMAT,
type_registry=TYPE_REGISTRY,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ requires-python = ">=3.9,<3.13"
dependencies = [
"wheel",
"async-property==0.2.2",
"async-substrate-interface>=1.0.5",
"async-substrate-interface>=1.0.7",
"aiohttp~=3.10.2",
"backoff~=2.2.1",
"GitPython>=3.0.0",
Expand Down
Loading