Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checking protocol version #3739

Merged
merged 7 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading