From 9c5f940b00f108923fcb98c66eddaf02bebebf91 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 4 Aug 2020 12:11:02 -0400 Subject: [PATCH] claim search forwarding to new sdk --- lbry/extras/daemon/daemon.py | 2 ++ lbry/wallet/ledger.py | 14 +++++++++----- lbry/wallet/network.py | 7 +++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index 4d7fcc3f6..55f72afea 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -2329,6 +2329,7 @@ class Daemon(metaclass=JSONRPCServerType): [--not_locations=...] [--order_by=...] [--page=] [--page_size=] [--wallet_id=] [--include_purchase_receipt] [--include_is_my_output] + [--new_sdk_server=] Options: --name= : (str) claim name (normalized) @@ -2434,6 +2435,7 @@ class Daemon(metaclass=JSONRPCServerType): has purchased the claim --include_is_my_output : (bool) lookup and include a boolean indicating if claim being resolved is yours + --new_sdk_server= : (str) use the new SDK server (EXPERIMENTAL) Returns: {Paginated[Output]} """ diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index 3cae9b845..d1a5b69c3 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -922,9 +922,9 @@ class Ledger(metaclass=LedgerRegistry): txo.received_tips = tips return txos, blocked, outputs.offset, outputs.total - async def resolve(self, accounts, urls, **kwargs): - if 'new_sdk_server' in kwargs: - resolve = partial(self.network.new_resolve, kwargs.pop('new_sdk_server')) + async def resolve(self, accounts, urls, new_sdk_server=None, **kwargs): + if new_sdk_server: + resolve = partial(self.network.new_resolve, new_sdk_server) else: resolve = partial(self.network.retriable_call, self.network.resolve) urls_copy = list(urls) @@ -946,9 +946,13 @@ class Ledger(metaclass=LedgerRegistry): async def claim_search( self, accounts, include_purchase_receipt=False, include_is_my_output=False, - **kwargs) -> Tuple[List[Output], dict, int, int]: + new_sdk_server=None, **kwargs) -> Tuple[List[Output], dict, int, int]: + if new_sdk_server: + claim_search = partial(self.network.new_claim_search, new_sdk_server) + else: + claim_search = self.network.claim_search return await self._inflate_outputs( - self.network.claim_search(**kwargs), accounts, + claim_search(**kwargs), accounts, include_purchase_receipt=include_purchase_receipt, include_is_my_output=include_is_my_output ) diff --git a/lbry/wallet/network.py b/lbry/wallet/network.py index 29f630c10..76d079895 100644 --- a/lbry/wallet/network.py +++ b/lbry/wallet/network.py @@ -328,6 +328,13 @@ class Network: result = await r.json() return result['result'] + async def new_claim_search(self, server, **kwargs): + kwargs['protobuf'] = True + message = {"method": "claim_search", "params": kwargs} + async with self.aiohttp_session.post(server, json=message) as r: + result = await r.json() + return result['result'] + class SessionPool: