diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index 211e3ef7a..d671b1e2a 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -894,9 +894,21 @@ class Ledger(metaclass=LedgerRegistry): hub_server=new_sdk_server is not None ) - 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 claim + # async def get_claim_by_claim_id(self, accounts, claim_id, **kwargs) -> Output: + # return await self.network.get_claim_by_id(claim_id) + + 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): try: diff --git a/lbry/wallet/network.py b/lbry/wallet/network.py index 240241a0c..0898d7e67 100644 --- a/lbry/wallet/network.py +++ b/lbry/wallet/network.py @@ -465,6 +465,12 @@ class Network: def get_server_features(self): 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): return self.rpc('blockchain.claimtrie.resolve', urls, False, session_override) diff --git a/lbry/wallet/server/session.py b/lbry/wallet/server/session.py index 364b623ab..d5b9ddd69 100644 --- a/lbry/wallet/server/session.py +++ b/lbry/wallet/server/session.py @@ -884,7 +884,8 @@ class LBRYElectrumX(SessionBase): 'blockchain.transaction.get_height': cls.transaction_get_height, 'blockchain.claimtrie.search': cls.claimtrie_search, '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, 'mempool.get_fee_histogram': cls.mempool_compact_histogram, 'blockchain.block.headers': cls.block_headers, @@ -1059,17 +1060,13 @@ class LBRYElectrumX(SessionBase): return -1 return None - async def claimtrie_getclaimsbyids(self, *claim_ids): - claims = await self.batched_formatted_claims_from_daemon(claim_ids) - return dict(zip(claim_ids, claims)) - - async def batched_formatted_claims_from_daemon(self, claim_ids): - claims = await self.daemon.getclaimsbyids(claim_ids) - result = [] - for claim in claims: - if claim and claim.get('value'): - result.append(self.format_claim_from_daemon(claim)) - return result + async def claimtrie_getclaimbyid(self, claim_id): + rows = [] + extra = [] + stream = await self.db.fs_getclaimbyid(claim_id) + rows.append(stream) + # print("claimtrie resolve %i rows %i extrat" % (len(rows), len(extra))) + return Outputs.to_base64(rows, extra, 0, None, 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."""