remove duplicate function

This commit is contained in:
Jack 2016-08-21 00:58:25 -04:00
parent 3d92413372
commit 15cfa45646
2 changed files with 6 additions and 20 deletions

View file

@ -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: ")

View file

@ -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,