Compare commits

...

1 commit

Author SHA1 Message Date
Victor Shyba
40ebf9ee5d update file list on resolve 2019-04-28 17:23:59 -03:00
2 changed files with 19 additions and 0 deletions

View file

@ -3524,6 +3524,7 @@ class Daemon(metaclass=JSONRPCServerType):
await self.storage.save_claims_for_resolve([
value for value in results.values() if 'error' not in value
])
await asyncio.create_task(self.stream_manager.check_from_resolve_response(results))
return results
async def get_claims_for_name(self, name: str):

View file

@ -5,6 +5,9 @@ import binascii
import logging
import random
from decimal import Decimal
from google.protobuf.message import DecodeError
from lbrynet.error import ResolveError, InvalidStreamDescriptorError, KeyFeeAboveMaxAllowed, InsufficientFundsError
from lbrynet.error import DownloadSDTimeout, DownloadDataTimeout, ResolveTimeout
from lbrynet.utils import cache_concurrent
@ -286,6 +289,21 @@ class StreamManager:
streams.reverse()
return streams
async def check_from_resolve_response(self, resolutions: dict):
futs = []
for uri, resolution in resolutions.items():
resolved = resolution if 'value' in resolution else resolution.get('claim')
if not resolved:
continue
outpoint = f"{resolved['txid']}:{resolved['nout']}"
try:
claim = Claim.from_bytes(binascii.unhexlify(resolved['protobuf']))
except DecodeError:
log.warning("Got an update for %s, but it doesn't decode. Skipping it.")
continue
futs.append(self._check_update_or_replace(outpoint, resolved['claim_id'], claim))
return await asyncio.gather(*futs)
async def _check_update_or_replace(self, outpoint: str, claim_id: str, claim: Claim) -> typing.Tuple[
typing.Optional[ManagedStream], typing.Optional[ManagedStream]]:
existing = self.get_filtered_streams(outpoint=outpoint)