pass-through for new support_sum api
This commit is contained in:
parent
24833ce9fb
commit
0a0ac3b7c9
4 changed files with 44 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -6,6 +6,7 @@
|
|||
/.coverage*
|
||||
/lbry-venv
|
||||
/venv
|
||||
/lbry/blockchain
|
||||
|
||||
lbry.egg-info
|
||||
__pycache__
|
||||
|
@ -17,4 +18,4 @@ _trial_temp/
|
|||
/lbry/wallet/bin
|
||||
|
||||
/.vscode
|
||||
/.gitignore
|
||||
/.gitignore
|
||||
|
|
|
@ -2295,6 +2295,39 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
kwargs['is_not_spent'] = True
|
||||
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)
|
||||
async def jsonrpc_claim_search(self, **kwargs):
|
||||
"""
|
||||
|
|
|
@ -945,6 +945,9 @@ class Ledger(metaclass=LedgerRegistry):
|
|||
result[url] = txo
|
||||
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(
|
||||
self, accounts, include_purchase_receipt=False, include_is_my_output=False,
|
||||
new_sdk_server=None, **kwargs) -> Tuple[List[Output], dict, int, int]:
|
||||
|
|
|
@ -335,6 +335,12 @@ class Network:
|
|||
result = await r.json()
|
||||
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:
|
||||
|
||||
|
|
Loading…
Reference in a new issue