Skip to content

Commit

Permalink
Handles websockets v14+
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhaleking committed Nov 12, 2024
1 parent 8e9aab6 commit b5eadb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bittensor/utils/async_substrate_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from hashlib import blake2b
from typing import Optional, Any, Union, Callable, Awaitable, cast

import websockets
from async_property import async_property
from bittensor_wallet import Keypair
from bt_decode import PortableRegistry, decode as decode_by_type_string, MetadataV15
from packaging import version
from scalecodec import GenericExtrinsic
from scalecodec.base import ScaleBytes, ScaleType, RuntimeConfigurationObject
from scalecodec.type_registry import load_type_registry_preset
Expand All @@ -20,6 +20,7 @@
BlockNotFound,
)
from substrateinterface.storage import StorageKey
import websockets

ResultHandler = Callable[[dict, Any], Awaitable[tuple[dict, bool]]]

Expand Down Expand Up @@ -768,14 +769,13 @@ def __init__(
"""
self.chain_endpoint = chain_endpoint
self.__chain = chain_name
self.ws = Websocket(
chain_endpoint,
options={
"max_size": 2**32,
"read_limit": 2**16,
"write_limit": 2**16,
},
)
options = {
"max_size": 2**32,
"write_limit": 2**16,
}
if version.parse(websockets.__version__) < version.parse("14.0"):
options.update({"read_limit": 2**16})
self.ws = Websocket(chain_endpoint, options=options)
self._lock = asyncio.Lock()
self.last_block_hash: Optional[str] = None
self.config = {
Expand Down
1 change: 1 addition & 0 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ python-Levenshtein
scalecodec==1.2.11
substrate-interface~=1.7.9
uvicorn
websockets>12.0
bittensor-wallet>=2.0.2

0 comments on commit b5eadb3

Please sign in to comment.