Skip to content

Commit

Permalink
LiteBalancer updates
Browse files Browse the repository at this point in the history
  • Loading branch information
yungwine committed May 10, 2024
1 parent ace3fb1 commit 903e849
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions pytoniq/liteclient/balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, peers: typing.List[LiteClient], timeout: int = 10):

self._peers = peers
self._alive_peers: typing.Set[int] = set()
self._archival_peers = set()

self._checker: asyncio.Task = None

Expand All @@ -29,15 +30,26 @@ def __init__(self, peers: typing.List[LiteClient], timeout: int = 10):
self._total_req_num = {} # {index: successful_requests_num}
self._current_req_num = {} # {index: current_waiting_requests_num}

self._archival_peers = set()

self._logger = logging.getLogger(self.__class__.__name__)

self.inited = False
self.max_req_per_peer = 100
self.max_retries = 1
self.timeout = timeout

@property
def peers_num(self):
return len(self._peers)

@property
def alive_peers_num(self):
return len(self._alive_peers)

@property
def archival_peers_num(self):
return len(self._archival_peers)


@property
def last_mc_block(self):
seqno = self._find_consensus_block()
Expand Down Expand Up @@ -449,6 +461,7 @@ async def close_all(self):
self._checker.cancel()
while not self._checker.done():
await asyncio.sleep(0)
self.inited = False

async def close(self):
raise BalancerError('Use .close_all()')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pytoniq",
version="0.1.36",
version="0.1.37",
author="Maksim Kurbatov",
author_email="[email protected]",
description="TON Blockchain SDK",
Expand Down

0 comments on commit 903e849

Please sign in to comment.