forked from LBRYCommunity/lbry-sdk
cleaned up resolve command
This commit is contained in:
parent
65c6c83b51
commit
8aa50aa14f
2 changed files with 11 additions and 14 deletions
|
@ -1437,17 +1437,15 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
return claim_results
|
return claim_results
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT)
|
@requires(WALLET_COMPONENT)
|
||||||
async def jsonrpc_resolve(self, force=False, uri=None, uris=None):
|
async def jsonrpc_resolve(self, url):
|
||||||
"""
|
"""
|
||||||
Get the claim that a URL refers to.
|
Get the claim that a URL refers to.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
resolve [--force] (<uri> | --uri=<uri>) [<uris>...]
|
resolve <url>...
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--force : (bool) force refresh and ignore cache
|
--url=<url> : (str) one or more urls to resolve
|
||||||
--uri=<uri> : (str) uri to resolve
|
|
||||||
--uris=<uris> : (list) uris to resolve
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dictionary of results, keyed by uri
|
Dictionary of results, keyed by uri
|
||||||
|
@ -1505,23 +1503,23 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
uris = tuple(uris or [])
|
urls = [url] if isinstance(url, str) else url
|
||||||
if uri is not None:
|
|
||||||
uris += (uri,)
|
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
valid_uris = tuple()
|
valid_urls = set()
|
||||||
for u in uris:
|
for u in urls:
|
||||||
try:
|
try:
|
||||||
parse_lbry_uri(u)
|
parse_lbry_uri(u)
|
||||||
valid_uris += (u,)
|
valid_urls.add(u)
|
||||||
except URIParseError:
|
except URIParseError:
|
||||||
results[u] = {"error": "%s is not a valid uri" % u}
|
results[u] = {"error": "%s is not a valid url" % u}
|
||||||
|
|
||||||
|
resolved = await self.wallet_manager.resolve(*tuple(valid_urls))
|
||||||
|
|
||||||
resolved = await self.wallet_manager.resolve(*valid_uris, check_cache=not force)
|
|
||||||
for resolved_uri in resolved:
|
for resolved_uri in resolved:
|
||||||
results[resolved_uri] = resolved[resolved_uri]
|
results[resolved_uri] = resolved[resolved_uri]
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT,
|
@requires(WALLET_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT,
|
||||||
|
|
|
@ -260,7 +260,6 @@ class LbryWalletManager(BaseWalletManager):
|
||||||
async def resolve(self, *uris, **kwargs):
|
async def resolve(self, *uris, **kwargs):
|
||||||
page = kwargs.get('page', 0)
|
page = kwargs.get('page', 0)
|
||||||
page_size = kwargs.get('page_size', 10)
|
page_size = kwargs.get('page_size', 10)
|
||||||
check_cache = kwargs.get('check_cache', False) # TODO: put caching back (was force_refresh parameter)
|
|
||||||
ledger: MainNetLedger = self.default_account.ledger
|
ledger: MainNetLedger = self.default_account.ledger
|
||||||
results = await ledger.resolve(page, page_size, *uris)
|
results = await ledger.resolve(page, page_size, *uris)
|
||||||
if 'error' not in results:
|
if 'error' not in results:
|
||||||
|
|
Loading…
Reference in a new issue