forked from LBRYCommunity/lbry-sdk
new resolve
This commit is contained in:
parent
bd83ee7931
commit
455b4043b8
3 changed files with 18 additions and 1 deletions
|
@ -986,10 +986,12 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
[--include_sent_supports]
|
[--include_sent_supports]
|
||||||
[--include_sent_tips]
|
[--include_sent_tips]
|
||||||
[--include_received_tips]
|
[--include_received_tips]
|
||||||
|
[--new_sdk_server=<new_sdk_server>]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--urls=<urls> : (str, list) one or more urls to resolve
|
--urls=<urls> : (str, list) one or more urls to resolve
|
||||||
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase reciepts
|
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase reciepts
|
||||||
|
--new_sdk_server=<new_sdk_server> : (str) use the new SDK server (EXPERIMENTAL)
|
||||||
--include_purchase_receipt : (bool) lookup and include a receipt if this wallet
|
--include_purchase_receipt : (bool) lookup and include a receipt if this wallet
|
||||||
has purchased the claim being resolved
|
has purchased the claim being resolved
|
||||||
--include_is_my_output : (bool) lookup and include a boolean indicating
|
--include_is_my_output : (bool) lookup and include a boolean indicating
|
||||||
|
|
|
@ -923,7 +923,10 @@ class Ledger(metaclass=LedgerRegistry):
|
||||||
return txos, blocked, outputs.offset, outputs.total
|
return txos, blocked, outputs.offset, outputs.total
|
||||||
|
|
||||||
async def resolve(self, accounts, urls, **kwargs):
|
async def resolve(self, accounts, urls, **kwargs):
|
||||||
resolve = partial(self.network.retriable_call, self.network.resolve)
|
if 'new_sdk_server' in kwargs:
|
||||||
|
resolve = partial(self.network.new_resolve, kwargs.pop('new_sdk_server'))
|
||||||
|
else:
|
||||||
|
resolve = partial(self.network.retriable_call, self.network.resolve)
|
||||||
urls_copy = list(urls)
|
urls_copy = list(urls)
|
||||||
txos = []
|
txos = []
|
||||||
while urls_copy:
|
while urls_copy:
|
||||||
|
|
|
@ -5,6 +5,8 @@ from time import perf_counter
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from typing import Dict, Optional, Tuple
|
from typing import Dict, Optional, Tuple
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
from lbry import __version__
|
from lbry import __version__
|
||||||
from lbry.error import IncompatibleWalletServerError
|
from lbry.error import IncompatibleWalletServerError
|
||||||
from lbry.wallet.rpc import RPCSession as BaseClientSession, Connector, RPCError, ProtocolError
|
from lbry.wallet.rpc import RPCSession as BaseClientSession, Connector, RPCError, ProtocolError
|
||||||
|
@ -181,6 +183,8 @@ class Network:
|
||||||
'blockchain.address.subscribe': self._on_status_controller,
|
'blockchain.address.subscribe': self._on_status_controller,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.aiohttp_session: Optional[aiohttp.ClientSession] = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def config(self):
|
def config(self):
|
||||||
return self.ledger.config
|
return self.ledger.config
|
||||||
|
@ -207,6 +211,7 @@ class Network:
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
self.running = True
|
self.running = True
|
||||||
|
self.aiohttp_session = aiohttp.ClientSession()
|
||||||
self._switch_task = asyncio.ensure_future(self.switch_forever())
|
self._switch_task = asyncio.ensure_future(self.switch_forever())
|
||||||
# this may become unnecessary when there are no more bugs found,
|
# this may become unnecessary when there are no more bugs found,
|
||||||
# but for now it helps understanding log reports
|
# but for now it helps understanding log reports
|
||||||
|
@ -217,6 +222,7 @@ class Network:
|
||||||
async def stop(self):
|
async def stop(self):
|
||||||
if self.running:
|
if self.running:
|
||||||
self.running = False
|
self.running = False
|
||||||
|
await self.aiohttp_session.close()
|
||||||
self._switch_task.cancel()
|
self._switch_task.cancel()
|
||||||
self.session_pool.stop()
|
self.session_pool.stop()
|
||||||
|
|
||||||
|
@ -316,6 +322,12 @@ class Network:
|
||||||
def claim_search(self, **kwargs):
|
def claim_search(self, **kwargs):
|
||||||
return self.rpc('blockchain.claimtrie.search', kwargs)
|
return self.rpc('blockchain.claimtrie.search', kwargs)
|
||||||
|
|
||||||
|
async def new_resolve(self, server, urls):
|
||||||
|
message = {"method": "resolve", "params": {"urls": urls, "protobuf": True}}
|
||||||
|
async with self.aiohttp_session.post(server, json=message) as r:
|
||||||
|
result = await r.json()
|
||||||
|
return result['result']
|
||||||
|
|
||||||
|
|
||||||
class SessionPool:
|
class SessionPool:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue