From 15cfa4564662a7953be6bc5c81c91b0aeaa34859 Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 21 Aug 2016 00:58:25 -0400 Subject: [PATCH] remove duplicate function --- lbrynet/lbrynet_daemon/LBRYDaemon.py | 24 +++++------------------- lbrynet/lbrynet_daemon/LBRYPublisher.py | 2 +- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index ac888b757..8b4cc54fb 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -1344,11 +1344,12 @@ class LBRYDaemon(jsonrpc.JSONRPC): if not lbry_file: return defer.fail(Exception("no lbry file given to reflect")) - sd_hash = lbry_file.sd_hash stream_hash = lbry_file.stream_hash - if sd_hash is None or stream_hash is None: - return defer.fail(Exception("unpopulated lbry file fields")) + if stream_hash is None: + return defer.fail(Exception("no stream hash")) + + log.info("Reflecting stream: %s" % stream_hash) reflector_server = random.choice(REFLECTOR_SERVERS) reflector_address, reflector_port = reflector_server[0], reflector_server[1] @@ -1938,26 +1939,11 @@ class LBRYDaemon(jsonrpc.JSONRPC): return m def _reflect_if_possible(sd_hash, txid): - log.info("Trying to start reflector") d = self._get_lbry_file('sd_hash', sd_hash, return_json=False) - d.addCallback(lambda r: False if not r else _start_reflector(r.stream_hash)) + d.addCallback(self._reflect) d.addCallback(lambda _: txid) return d - def _start_reflector(stream_hash): - reflector_server = random.choice(REFLECTOR_SERVERS) - reflector_address, reflector_port = reflector_server[0], reflector_server[1] - log.info("Start reflector client") - factory = reflector.ClientFactory( - self.session.blob_manager, - self.lbry_file_manager.stream_info_manager, - stream_hash - ) - d = reactor.resolve(reflector_address) - d.addCallback(lambda ip: reactor.connectTCP(ip, reflector_port, factory)) - d.addCallback(lambda _: factory.finished_deferred) - return d - name = p['name'] log.info("Publish: ") diff --git a/lbrynet/lbrynet_daemon/LBRYPublisher.py b/lbrynet/lbrynet_daemon/LBRYPublisher.py index 5efbe66a9..04b9bdaab 100644 --- a/lbrynet/lbrynet_daemon/LBRYPublisher.py +++ b/lbrynet/lbrynet_daemon/LBRYPublisher.py @@ -72,7 +72,7 @@ class Publisher(object): def start_reflector(self): reflector_server = random.choice(REFLECTOR_SERVERS) reflector_address, reflector_port = reflector_server[0], reflector_server[1] - log.info("Start reflector client") + log.info("Reflecting new publication") factory = reflector.ClientFactory( self.session.blob_manager, self.lbry_file_manager.stream_info_manager,