From 9e5ac6f73e2158d6d0e54cbd2c13e2337d68a944 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 28 Mar 2017 17:13:21 -0400 Subject: [PATCH 1/2] typo --- lbrynet/core/Session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lbrynet/core/Session.py b/lbrynet/core/Session.py index 61541bec1..78907aec4 100644 --- a/lbrynet/core/Session.py +++ b/lbrynet/core/Session.py @@ -221,7 +221,7 @@ class Session(object): self.dht_node_port, 'UDP', u.lanaddr, self.dht_node_port, 'LBRY DHT port', '') self.upnp_redirects.append((self.dht_node_port, 'UDP')) - log.info("Set UPnP redirect for UPD port %d", self.dht_node_port) + log.info("Set UPnP redirect for UDP port %d", self.dht_node_port) else: # TODO: check that the existing redirect was # put up by an old lbrynet session before From 84d9461debc7c972278aaf2739813d44e9b9a84e Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 28 Mar 2017 17:13:59 -0400 Subject: [PATCH 2/2] Minor wallet updates --- lbrynet/core/Wallet.py | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lbrynet/core/Wallet.py b/lbrynet/core/Wallet.py index 86834a9d7..1c56b17f7 100644 --- a/lbrynet/core/Wallet.py +++ b/lbrynet/core/Wallet.py @@ -1021,22 +1021,26 @@ class LBRYumWallet(Wallet): def _get_claims_for_name(self, name): return self._run_cmd_as_defer_to_thread('getclaimsforname', name) + @defer.inlineCallbacks def _send_name_claim(self, name, val, amount): broadcast = False log.debug("Name claim %s %s %f", name, val, amount) - d = self._run_cmd_as_defer_succeed('claim', name, json.dumps(val), amount, broadcast) - d.addCallback(lambda claim_out: self._broadcast_claim_transaction(claim_out)) - return d + tx = yield self._run_cmd_as_defer_succeed('claim', name, json.dumps(val), amount, broadcast) + claim_out = yield self._broadcast_claim_transaction(tx) + defer.returnValue(claim_out) + @defer.inlineCallbacks def _send_name_claim_update(self, name, claim_id, claim_outpoint, value, amount): metadata = json.dumps(value) log.debug("Update %s %d %f %s %s '%s'", claim_outpoint['txid'], claim_outpoint['nout'], amount, name, claim_id, metadata) broadcast = False - d = self._run_cmd_as_defer_succeed('update', claim_outpoint['txid'], claim_outpoint['nout'], - name, claim_id, metadata, amount, broadcast) - d.addCallback(lambda claim_out: self._broadcast_claim_transaction(claim_out)) - return d + tx = yield self._run_cmd_as_defer_succeed( + 'update', claim_outpoint['txid'], claim_outpoint['nout'], + name, claim_id, metadata, amount, broadcast + ) + claim_out = yield self._broadcast_claim_transaction(tx) + defer.returnValue(claim_out) @defer.inlineCallbacks def _abandon_claim(self, claim_outpoint): @@ -1048,33 +1052,29 @@ class LBRYumWallet(Wallet): claim_out = yield self._broadcast_claim_transaction(abandon_tx) defer.returnValue(claim_out) + @defer.inlineCallbacks def _support_claim(self, name, claim_id, amount): log.debug("Support %s %s %f" % (name, claim_id, amount)) broadcast = False - d = self._run_cmd_as_defer_succeed('support', name, claim_id, amount, broadcast) - d.addCallback(lambda claim_out: self._broadcast_claim_transaction(claim_out)) - return d + tx = yield self._run_cmd_as_defer_succeed('support', name, claim_id, amount, broadcast) + claim_out = yield self._broadcast_claim_transaction(tx) + defer.returnValue(claim_out) + @defer.inlineCallbacks def _broadcast_claim_transaction(self, claim_out): if 'success' not in claim_out: - raise Exception('Unexpected claim command output:{}'.format(claim_out)) + raise Exception('Unexpected claim command output: {}'.format(claim_out)) if claim_out['success']: - d = self._broadcast_transaction(claim_out['tx']) - d.addCallback(lambda _: claim_out) - return d - else: - return defer.succeed(claim_out) + yield self._broadcast_transaction(claim_out['tx']) + defer.returnValue(claim_out) + @defer.inlineCallbacks def _broadcast_transaction(self, raw_tx): - def _log_tx(r): - log.debug("Broadcast tx: %s", r) - return r - - d = self._run_cmd_as_defer_to_thread('broadcast', raw_tx) - d.addCallback(_log_tx) - d.addCallback( - lambda r: r if len(r) == 64 else defer.fail(Exception("Transaction rejected"))) - return d + txid = yield self._run_cmd_as_defer_to_thread('broadcast', raw_tx) + log.info("Broadcast tx: %s", txid) + if len(txid) != 64: + raise Exception("Transaction rejected. Raw tx: {}".format(raw_tx)) + defer.returnValue(txid) def _do_send_many(self, payments_to_send): def broadcast_send_many(paytomany_out):