From 3589cc9977e4229348753e2dd8035d18af928733 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 31 Jan 2019 12:30:31 -0500 Subject: [PATCH] call update_reflected_stream upon reflector finishing --- lbrynet/extras/daemon/Daemon.py | 7 ++++++- lbrynet/extras/daemon/storage.py | 3 ++- lbrynet/stream/managed_stream.py | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index 20a46bcf4..217dfca0a 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -2061,6 +2061,7 @@ class Daemon(metaclass=JSONRPCServerType): await self.storage.save_content_claim( stream_hash, tx.outputs[0].id ) + await self.analytics_manager.send_claim_action('publish') nout = 0 txo = tx.outputs[nout] @@ -2794,10 +2795,14 @@ class Daemon(metaclass=JSONRPCServerType): port = int(port) else: server, port = random.choice(self.conf.reflector_servers) - return await asyncio.gather(*[ + reflected = await asyncio.gather(*[ stream.upload_to_reflector(server, port) for stream in self.stream_manager.get_filtered_streams(**kwargs) ]) + total = [] + for reflected_for_stream in reflected: + total.extend(reflected_for_stream) + return total @requires(DHT_COMPONENT) async def jsonrpc_peer_ping(self, node_id, address, port): diff --git a/lbrynet/extras/daemon/storage.py b/lbrynet/extras/daemon/storage.py index 941c08c72..c808ab046 100644 --- a/lbrynet/extras/daemon/storage.py +++ b/lbrynet/extras/daemon/storage.py @@ -3,6 +3,7 @@ import sqlite3 import typing import asyncio import binascii +import time from torba.client.basedatabase import SQLiteMixin from lbrynet.conf import Config from lbrynet.extras.wallet.dewies import dewies_to_lbc, lbc_to_dewies @@ -682,7 +683,7 @@ class SQLiteStorage(SQLiteMixin): if success: return self.db.execute( "insert or replace into reflected_stream values (?, ?, ?)", - (sd_hash, reflector_address, self.loop.time()) + (sd_hash, reflector_address, time.time()) ) return self.db.execute( "delete from reflected_stream where sd_hash=? and reflector_address=?", diff --git a/lbrynet/stream/managed_stream.py b/lbrynet/stream/managed_stream.py index 9298ee43e..216f3186e 100644 --- a/lbrynet/stream/managed_stream.py +++ b/lbrynet/stream/managed_stream.py @@ -179,6 +179,8 @@ class ManagedStream: if not sent_sd and not needed: if not self.fully_reflected.is_set(): self.fully_reflected.set() + await self.blob_manager.storage.update_reflected_stream(self.sd_hash, f"{host}:{port}") + return [] except (asyncio.CancelledError, asyncio.TimeoutError, ValueError): if protocol.transport: protocol.transport.close() @@ -195,4 +197,5 @@ class ManagedStream: protocol.transport.close() if not self.fully_reflected.is_set(): self.fully_reflected.set() + await self.blob_manager.storage.update_reflected_stream(self.sd_hash, f"{host}:{port}") return sent