get_claim_by_claim_id
This commit is contained in:
parent
b40cda78ee
commit
d57cd5acd7
3 changed files with 30 additions and 15 deletions
|
@ -894,9 +894,21 @@ class Ledger(metaclass=LedgerRegistry):
|
||||||
hub_server=new_sdk_server is not None
|
hub_server=new_sdk_server is not None
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_claim_by_claim_id(self, accounts, claim_id, **kwargs) -> Output:
|
# async def get_claim_by_claim_id(self, accounts, claim_id, **kwargs) -> Output:
|
||||||
for claim in (await self.claim_search(accounts, claim_id=claim_id, **kwargs))[0]:
|
# return await self.network.get_claim_by_id(claim_id)
|
||||||
return claim
|
|
||||||
|
async def get_claim_by_claim_id(self, claim_id, accounts=None, include_purchase_receipt=False,
|
||||||
|
include_is_my_output=False):
|
||||||
|
accounts = accounts or []
|
||||||
|
# return await self.network.get_claim_by_id(claim_id)
|
||||||
|
inflated = await self._inflate_outputs(
|
||||||
|
self.network.get_claim_by_id(claim_id), accounts,
|
||||||
|
include_purchase_receipt=include_purchase_receipt,
|
||||||
|
include_is_my_output=include_is_my_output,
|
||||||
|
)
|
||||||
|
txos = inflated[0]
|
||||||
|
if txos:
|
||||||
|
return txos[0]
|
||||||
|
|
||||||
async def _report_state(self):
|
async def _report_state(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -465,6 +465,12 @@ class Network:
|
||||||
def get_server_features(self):
|
def get_server_features(self):
|
||||||
return self.rpc('server.features', (), restricted=True)
|
return self.rpc('server.features', (), restricted=True)
|
||||||
|
|
||||||
|
# def get_claims_by_ids(self, claim_ids):
|
||||||
|
# return self.rpc('blockchain.claimtrie.getclaimsbyids', claim_ids)
|
||||||
|
|
||||||
|
def get_claim_by_id(self, claim_id):
|
||||||
|
return self.rpc('blockchain.claimtrie.getclaimbyid', [claim_id])
|
||||||
|
|
||||||
def resolve(self, urls, session_override=None):
|
def resolve(self, urls, session_override=None):
|
||||||
return self.rpc('blockchain.claimtrie.resolve', urls, False, session_override)
|
return self.rpc('blockchain.claimtrie.resolve', urls, False, session_override)
|
||||||
|
|
||||||
|
|
|
@ -884,7 +884,8 @@ class LBRYElectrumX(SessionBase):
|
||||||
'blockchain.transaction.get_height': cls.transaction_get_height,
|
'blockchain.transaction.get_height': cls.transaction_get_height,
|
||||||
'blockchain.claimtrie.search': cls.claimtrie_search,
|
'blockchain.claimtrie.search': cls.claimtrie_search,
|
||||||
'blockchain.claimtrie.resolve': cls.claimtrie_resolve,
|
'blockchain.claimtrie.resolve': cls.claimtrie_resolve,
|
||||||
'blockchain.claimtrie.getclaimsbyids': cls.claimtrie_getclaimsbyids,
|
'blockchain.claimtrie.getclaimbyid': cls.claimtrie_getclaimbyid,
|
||||||
|
# 'blockchain.claimtrie.getclaimsbyids': cls.claimtrie_getclaimsbyids,
|
||||||
'blockchain.block.get_server_height': cls.get_server_height,
|
'blockchain.block.get_server_height': cls.get_server_height,
|
||||||
'mempool.get_fee_histogram': cls.mempool_compact_histogram,
|
'mempool.get_fee_histogram': cls.mempool_compact_histogram,
|
||||||
'blockchain.block.headers': cls.block_headers,
|
'blockchain.block.headers': cls.block_headers,
|
||||||
|
@ -1059,17 +1060,13 @@ class LBRYElectrumX(SessionBase):
|
||||||
return -1
|
return -1
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def claimtrie_getclaimsbyids(self, *claim_ids):
|
async def claimtrie_getclaimbyid(self, claim_id):
|
||||||
claims = await self.batched_formatted_claims_from_daemon(claim_ids)
|
rows = []
|
||||||
return dict(zip(claim_ids, claims))
|
extra = []
|
||||||
|
stream = await self.db.fs_getclaimbyid(claim_id)
|
||||||
async def batched_formatted_claims_from_daemon(self, claim_ids):
|
rows.append(stream)
|
||||||
claims = await self.daemon.getclaimsbyids(claim_ids)
|
# print("claimtrie resolve %i rows %i extrat" % (len(rows), len(extra)))
|
||||||
result = []
|
return Outputs.to_base64(rows, extra, 0, None, None)
|
||||||
for claim in claims:
|
|
||||||
if claim and claim.get('value'):
|
|
||||||
result.append(self.format_claim_from_daemon(claim))
|
|
||||||
return result
|
|
||||||
|
|
||||||
def format_claim_from_daemon(self, claim, name=None):
|
def format_claim_from_daemon(self, claim, name=None):
|
||||||
"""Changes the returned claim data to the format expected by lbry and adds missing fields."""
|
"""Changes the returned claim data to the format expected by lbry and adds missing fields."""
|
||||||
|
|
Loading…
Reference in a new issue