Skip to content

Commit

Permalink
Fix checking protocol version
Browse files Browse the repository at this point in the history
  • Loading branch information
ben221199 committed May 21, 2024
1 parent eb5da95 commit a471dcb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lbry/wallet/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ async def send_request(self, method, args=()):
self._concurrency.release()

async def ensure_server_version(self, required=None, timeout=3):
required = required or self.network.PROTOCOL_VERSION
required = required or self.network.PROTOCOL_MAX_VERSION
response = await asyncio.wait_for(
self.send_request('server.version', [__version__, required]), timeout=timeout
self.send_request('server.version', [self.network.CLIENT_NAME, required]), timeout=timeout
)
if tuple(int(piece) for piece in response[0].split(".")) < self.network.MINIMUM_REQUIRED:
raise IncompatibleWalletServerError(*self.server)
return response
if tuple(int(piece) for piece in response[1].split(".")) >= self.network.PROTOCOL_MIN_VERSION:
return response
raise IncompatibleWalletServerError(*self.server)

async def keepalive_loop(self, timeout=3, max_idle=60):
try:
Expand Down Expand Up @@ -149,8 +149,11 @@ def connection_lost(self, exc):

class Network:

PROTOCOL_VERSION = __version__
MINIMUM_REQUIRED = (0, 65, 0)
CLIENT_VERSION = __version__
CLIENT_NAME = "LBRY SDK " + CLIENT_VERSION

PROTOCOL_MIN_VERSION = (0, 65, 0)
PROTOCOL_MAX_VERSION = __version__

def __init__(self, ledger):
self.ledger = ledger
Expand Down

0 comments on commit a471dcb

Please sign in to comment.