From 903e849ccad8a1ab6834ca394e766a12d334cc48 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 10 May 2024 12:25:46 +0700 Subject: [PATCH] LiteBalancer updates --- pytoniq/liteclient/balancer.py | 17 +++++++++++++++-- setup.py | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pytoniq/liteclient/balancer.py b/pytoniq/liteclient/balancer.py index 797c069..2360b92 100644 --- a/pytoniq/liteclient/balancer.py +++ b/pytoniq/liteclient/balancer.py @@ -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 @@ -29,8 +30,6 @@ 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 @@ -38,6 +37,19 @@ def __init__(self, peers: typing.List[LiteClient], timeout: int = 10): 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() @@ -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()') diff --git a/setup.py b/setup.py index 5b28cc3..283577b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="pytoniq", - version="0.1.36", + version="0.1.37", author="Maksim Kurbatov", author_email="cyrbatoff@gmail.com", description="TON Blockchain SDK",