diff --git a/lbry/lbry/wallet/server/session.py b/lbry/lbry/wallet/server/session.py index 30d78f37d..82ac1574c 100644 --- a/lbry/lbry/wallet/server/session.py +++ b/lbry/lbry/wallet/server/session.py @@ -95,7 +95,8 @@ class LBRYSessionManager(SessionManager): class LBRYElectrumX(ElectrumX): - PROTOCOL_MIN = (0, 0) # temporary, for supporting 0.10 protocol + PROTOCOL_MIN = (2, 0) # v0.48 is backwards incompatible, forking a new protocol + PROTOCOL_MAX = (2, 0) max_errors = math.inf # don't disconnect people for errors! let them happen... session_mgr: LBRYSessionManager version = sdk_version @@ -111,7 +112,7 @@ class LBRYElectrumX(ElectrumX): self.filtering_channels_ids = list(filter(None, filtering_channels.split(' '))) def set_request_handlers(self, ptuple): - super().set_request_handlers(ptuple) + super().set_request_handlers((1, 2) if ptuple == (2, 0) else ptuple) # our "2.0" is electrumx 1.2 handlers = { 'blockchain.transaction.get_height': self.transaction_get_height, 'blockchain.claimtrie.search': self.claimtrie_search, diff --git a/torba/torba/client/basenetwork.py b/torba/torba/client/basenetwork.py index 3d7e155e8..caa37c683 100644 --- a/torba/torba/client/basenetwork.py +++ b/torba/torba/client/basenetwork.py @@ -13,6 +13,8 @@ log = logging.getLogger(__name__) class ClientSession(BaseClientSession): + PROTOCOL_VERSION = '2.0' + def __init__(self, *args, network, server, timeout=30, on_connect_callback=None, **kwargs): self.network = network self.server = server @@ -102,6 +104,9 @@ class ClientSession(BaseClientSession): if (perf_counter() - self.last_send) > self.max_seconds_idle or self.response_time is None: await self.ensure_server_version() retry_delay = default_delay + except RPCError as e: + log.warning("Server error, ignoring for 1h: %s:%d -- %s", *self.server, e.message) + retry_delay = 60 * 60 except (asyncio.TimeoutError, OSError): await self.close() retry_delay = min(60, retry_delay * 2) @@ -113,9 +118,10 @@ class ClientSession(BaseClientSession): finally: self.trigger_urgent_reconnect.clear() - async def ensure_server_version(self, required='1.2', timeout=3): + async def ensure_server_version(self, required=None, timeout=3): return await asyncio.wait_for( - self.send_request('server.version', [__version__, required]), timeout=timeout + self.send_request( + 'server.version', [__version__, required or self.PROTOCOL_VERSION]), timeout=timeout ) async def create_connection(self, timeout=6):