Fixes errback not being callable

Small code refactoring to make it more obvious what
both the callback and errback are doing
This commit is contained in:
Job Evers-Meltzer 2016-07-27 13:12:20 -05:00
parent 6a1efedc1f
commit 900d3ad01d

View file

@ -609,12 +609,27 @@ class LBRYDaemon(jsonrpc.JSONRPC):
d.addCallback(lambda _: self._get_lbry_file("name", name, return_json=False)) d.addCallback(lambda _: self._get_lbry_file("name", name, return_json=False))
d.addCallback(lambda l: _start_file(l) if l.stopped else "LBRY file was already running") d.addCallback(lambda l: _start_file(l) if l.stopped else "LBRY file was already running")
def _process_lbry_file(name, lbry_file):
ready_to_start = (
self.pending_claims[name] == lbry_file['txid'] and
not isinstance(lbry_file['metadata'], str)
)
if ready_to_start:
_start_file(name)
else:
re_add_to_pending_claims(name)
def re_add_to_pending_claims(name):
self._add_to_pending_claims(name, self.pending_claims.pop(name)),
for name in self.pending_claims: for name in self.pending_claims:
log.info("Checking if new claim for lbry://%s is confirmed" % name) log.info("Checking if new claim for lbry://%s is confirmed" % name)
d = self._resolve_name(name, force_refresh=True) d = self._resolve_name(name, force_refresh=True)
d.addCallback(lambda _: self._get_lbry_file_by_uri(name)) d.addCallback(lambda _: self._get_lbry_file_by_uri(name))
d.addCallbacks(lambda lbry_file: _start_file(name) if self.pending_claims[name] == lbry_file['txid'] and not isinstance(lbry_file['metadata'], str) else self._add_to_pending_claims(name, self.pending_claims.pop(name)), d.addCallbacks(
self._add_to_pending_claims(name, self.pending_claims.pop(name))) lambda lbry_file: _process_lbry_file(name, lbry_file),
lambda _: re_add_to_pending_claims(name)
)
def _start_server(self): def _start_server(self):
if self.peer_port is not None: if self.peer_port is not None: