pass-through for new support_sum api

This commit is contained in:
Alex Grintsvayg 2020-10-13 15:51:59 -04:00 committed by Lex Berezhny
parent 24833ce9fb
commit 0a0ac3b7c9
4 changed files with 44 additions and 1 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@
/.coverage* /.coverage*
/lbry-venv /lbry-venv
/venv /venv
/lbry/blockchain
lbry.egg-info lbry.egg-info
__pycache__ __pycache__

View file

@ -2295,6 +2295,39 @@ class Daemon(metaclass=JSONRPCServerType):
kwargs['is_not_spent'] = True kwargs['is_not_spent'] = True
return self.jsonrpc_txo_list(**kwargs) return self.jsonrpc_txo_list(**kwargs)
async def jsonrpc_support_sum(self, claim_id, new_sdk_server, include_channel_content=False, **kwargs):
"""
List total staked supports for a claim, grouped by the channel that signed the support.
+
+ If claim_id is a channel claim, you can use --include_channel_content to also include supports for
+ content claims in the channel.
!!!! NOTE: PAGINATION DOES NOT DO ANYTHING AT THE MOMENT !!!!!
Usage:
support_sum <claim_id> <new_sdk_server>
[--include_channel_content]
[--page=<page>] [--page_size=<page_size>]
Options:
--claim_id=<claim_id> : (str) claim id
--new_sdk_server=<new_sdk_server> : (str) URL of the new SDK server (EXPERIMENTAL)
--include_channel_content : (bool) if claim_id is for a channel, include supports for claims in
that channel
--page=<page> : (int) page to return during paginating
--page_size=<page_size> : (int) number of items on page during pagination
Returns: {Paginated[Dict]}
"""
page_num, page_size = abs(kwargs.pop('page', 1)), min(abs(kwargs.pop('page_size', DEFAULT_PAGE_SIZE)), 50)
kwargs.update({'offset': page_size * (page_num - 1), 'limit': page_size})
support_sums = await self.ledger.sum_supports(new_sdk_server, claim_id=claim_id, include_channel_content=include_channel_content, **kwargs)
return {
"items": support_sums,
"page": page_num,
"page_size": page_size
}
@requires(WALLET_COMPONENT) @requires(WALLET_COMPONENT)
async def jsonrpc_claim_search(self, **kwargs): async def jsonrpc_claim_search(self, **kwargs):
""" """

View file

@ -945,6 +945,9 @@ class Ledger(metaclass=LedgerRegistry):
result[url] = txo result[url] = txo
return result return result
async def sum_supports(self, new_sdk_server, **kwargs) -> List[Dict]:
return await self.network.sum_supports(new_sdk_server, **kwargs)
async def claim_search( async def claim_search(
self, accounts, include_purchase_receipt=False, include_is_my_output=False, self, accounts, include_purchase_receipt=False, include_is_my_output=False,
new_sdk_server=None, **kwargs) -> Tuple[List[Output], dict, int, int]: new_sdk_server=None, **kwargs) -> Tuple[List[Output], dict, int, int]:

View file

@ -335,6 +335,12 @@ class Network:
result = await r.json() result = await r.json()
return result['result'] return result['result']
async def sum_supports(self, server, **kwargs):
message = {"method": "support_sum", "params": kwargs}
async with self.aiohttp_session.post(server, json=message) as r:
result = await r.json()
return result['result']
class SessionPool: class SessionPool: