diff --git a/lbrynet/stream/managed_stream.py b/lbrynet/stream/managed_stream.py index a3c75a7d7..f56c8e954 100644 --- a/lbrynet/stream/managed_stream.py +++ b/lbrynet/stream/managed_stream.py @@ -2,13 +2,14 @@ import os import asyncio import typing import logging +import binascii from lbrynet.extras.daemon.mime_types import guess_media_type from lbrynet.stream.downloader import StreamDownloader from lbrynet.stream.descriptor import StreamDescriptor from lbrynet.stream.reflector.client import StreamReflectorClient -from lbrynet.schema.claim import ClaimDict +from lbrynet.extras.daemon.storage import StoredStreamClaim if typing.TYPE_CHECKING: - from lbrynet.extras.daemon.storage import StoredStreamClaim + from lbrynet.schema.claim import ClaimDict from lbrynet.blob.blob_manager import BlobFileManager log = logging.getLogger(__name__) @@ -21,7 +22,7 @@ class ManagedStream: def __init__(self, loop: asyncio.BaseEventLoop, blob_manager: 'BlobFileManager', descriptor: 'StreamDescriptor', download_directory: str, file_name: str, downloader: typing.Optional[StreamDownloader] = None, - status: typing.Optional[str] = STATUS_STOPPED, claim: typing.Optional['StoredStreamClaim'] = None): + status: typing.Optional[str] = STATUS_STOPPED, claim: typing.Optional[StoredStreamClaim] = None): self.loop = loop self.blob_manager = blob_manager self.download_directory = download_directory @@ -201,10 +202,10 @@ class ManagedStream: await self.blob_manager.storage.update_reflected_stream(self.sd_hash, f"{host}:{port}") return sent - def set_claim(self, claim_info: typing.Dict, claim: ClaimDict): + def set_claim(self, claim_info: typing.Dict, claim: 'ClaimDict'): self.stream_claim_info = StoredStreamClaim( self.stream_hash, f"{claim_info['txid']}:{claim_info['nout']}", claim_info['claim_id'], - claim_info['name'], claim_info['amount'], claim_info['height'], claim_info['hex'], - claim.certificate_id, claim_info['address'], claim_info['claim_sequence'], - claim_info.get('channel_name') + claim_info['name'], claim_info['amount'], claim_info['height'], + binascii.hexlify(claim.serialized).decode(), claim.certificate_id, claim_info['address'], + claim_info['claim_sequence'], claim_info.get('channel_name') ) diff --git a/lbrynet/stream/stream_manager.py b/lbrynet/stream/stream_manager.py index 50a673c18..b142b9c7b 100644 --- a/lbrynet/stream/stream_manager.py +++ b/lbrynet/stream/stream_manager.py @@ -7,6 +7,7 @@ import random from lbrynet.stream.downloader import StreamDownloader from lbrynet.stream.managed_stream import ManagedStream from lbrynet.schema.claim import ClaimDict +from lbrynet.schema.decode import smart_decode from lbrynet.extras.daemon.storage import lbc_to_dewies if typing.TYPE_CHECKING: from lbrynet.conf import Config @@ -61,7 +62,7 @@ class StreamManager: async def _update_content_claim(self, stream: ManagedStream): claim_info = await self.storage.get_content_claim(stream.stream_hash) - stream.set_claim(claim_info, ClaimDict.load_dict(claim_info['value'])) + stream.set_claim(claim_info, smart_decode(claim_info['value'])) async def load_streams_from_database(self): infos = await self.storage.get_all_lbry_files() @@ -166,7 +167,7 @@ class StreamManager: async def _download_stream_from_claim(self, node: 'Node', download_directory: str, claim_info: typing.Dict, file_name: typing.Optional[str] = None) -> typing.Optional[ManagedStream]: - claim = ClaimDict.load_dict(claim_info['value']) + claim = smart_decode(claim_info['value']) downloader = StreamDownloader(self.loop, self.config, self.blob_manager, claim.source_hash.decode(), download_directory, file_name) try: diff --git a/tests/integration/wallet/test_commands.py b/tests/integration/wallet/test_commands.py index c6ac863c1..66a022a42 100644 --- a/tests/integration/wallet/test_commands.py +++ b/tests/integration/wallet/test_commands.py @@ -44,6 +44,7 @@ class CommandTestCase(IntegrationTestCase): conf.reflect_streams = False conf.blockchain_name = 'lbrycrd_regtest' conf.lbryum_servers = [('localhost', 50001)] + conf.reflector_servers = [] conf.known_dht_nodes = [] await self.account.ensure_address_gap()