From e49f0f99a1820d95a8a64d2c40ff223955325d22 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 22 Aug 2016 16:57:22 -0400 Subject: [PATCH 1/4] LBRYcrdWallet update claim fix -fix log line that could raise an exception -json encode value sent to lbrycrd-cli updateclaim --- lbrynet/core/LBRYWallet.py | 2 +- lbrynet/core/client/ConnectionManager.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lbrynet/core/LBRYWallet.py b/lbrynet/core/LBRYWallet.py index 7d275278b..459b28568 100644 --- a/lbrynet/core/LBRYWallet.py +++ b/lbrynet/core/LBRYWallet.py @@ -989,7 +989,7 @@ class LBRYcrdWallet(LBRYWallet): @_catch_connection_error def _update_name_rpc(self, txid, value, amount): rpc_conn = self._get_rpc_conn() - return rpc_conn.updateclaim(txid, value, amount) + return rpc_conn.updateclaim(txid, json.dumps(value), amount) @_catch_connection_error def _send_name_claim_rpc(self, name, value, amount): diff --git a/lbrynet/core/client/ConnectionManager.py b/lbrynet/core/client/ConnectionManager.py index f82f19a20..6cff01156 100644 --- a/lbrynet/core/client/ConnectionManager.py +++ b/lbrynet/core/client/ConnectionManager.py @@ -172,7 +172,8 @@ class ConnectionManager(object): def pick_best_peer(peers): # TODO: Eventually rank them based on past performance/reputation. For now # TODO: just pick the first to which we don't have an open connection - log.debug("Got a list of peers to choose from: %s", str(["%s:%i" % (p.host, p.port) for p in peers])) + + log.debug("Got a list of peers to choose from: %s", str(peers)) if peers is None: return None for peer in peers: From 5727c708cf78175cf0de4fccfd2dab62a46b974d Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 22 Aug 2016 18:43:52 -0400 Subject: [PATCH 2/4] fix get_transaction previously get_tx_json was only in LBRYumWallet --- lbrynet/core/LBRYWallet.py | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lbrynet/core/LBRYWallet.py b/lbrynet/core/LBRYWallet.py index 459b28568..99f4939fe 100644 --- a/lbrynet/core/LBRYWallet.py +++ b/lbrynet/core/LBRYWallet.py @@ -493,6 +493,29 @@ class LBRYWallet(object): d = self._get_history() return d + def get_tx_json(self, txid): + def _decode(raw_tx): + tx = Transaction(raw_tx).deserialize() + decoded_tx = {} + for txkey in tx.keys(): + if isinstance(tx[txkey], list): + decoded_tx[txkey] = [] + for i in tx[txkey]: + tmp = {} + for k in i.keys(): + if isinstance(i[k], Decimal): + tmp[k] = float(i[k] / 1e8) + else: + tmp[k] = i[k] + decoded_tx[txkey].append(tmp) + else: + decoded_tx[txkey] = tx[txkey] + return decoded_tx + + d = self._get_raw_tx(txid) + d.addCallback(_decode) + return d + def get_name_and_validity_for_sd_hash(self, sd_hash): d = self._get_claim_metadata_for_sd_hash(sd_hash) d.addCallback(lambda name_txid: self._get_status_of_claim(name_txid[1], name_txid[0], sd_hash) if name_txid is not None else None) @@ -1314,29 +1337,6 @@ class LBRYumWallet(LBRYWallet): func = getattr(self.cmd_runner, cmd.name) return threads.deferToThread(func) - def get_tx_json(self, txid): - def _decode(raw_tx): - tx = Transaction(raw_tx).deserialize() - decoded_tx = {} - for txkey in tx.keys(): - if isinstance(tx[txkey], list): - decoded_tx[txkey] = [] - for i in tx[txkey]: - tmp = {} - for k in i.keys(): - if isinstance(i[k], Decimal): - tmp[k] = float(i[k] / 1e8) - else: - tmp[k] = i[k] - decoded_tx[txkey].append(tmp) - else: - decoded_tx[txkey] = tx[txkey] - return decoded_tx - - d = self._get_raw_tx(txid) - d.addCallback(_decode) - return d - def get_pub_keys(self, wallet): cmd = known_commands['getpubkeys'] func = getattr(self.cmd_runner, cmd.name) From 95f4b29be54143454360464fe7b336c02926c9b1 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 22 Aug 2016 18:59:17 -0400 Subject: [PATCH 3/4] noisy log --- lbrynet/core/log_support.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lbrynet/core/log_support.py b/lbrynet/core/log_support.py index c2f652e74..8ca5b2b9b 100644 --- a/lbrynet/core/log_support.py +++ b/lbrynet/core/log_support.py @@ -81,6 +81,7 @@ def disable_noisy_loggers(): logging.getLogger('lbrynet.core.client.BlobRequester').setLevel(logging.INFO) logging.getLogger('lbrynet.core.client.ClientProtocol').setLevel(logging.INFO) logging.getLogger('lbrynet.analytics.api').setLevel(logging.INFO) + logging.getLogger('BitcoinRPC').setLevel(logging.INFO) @_log_decorator From 128b32c62c7c6ff303bc2c29ce2a8ab6355df30a Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 22 Aug 2016 19:56:42 -0400 Subject: [PATCH 4/4] even less noisy logs --- lbrynet/core/LBRYWallet.py | 2 +- lbrynet/core/log_support.py | 10 +++++++--- lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lbrynet/core/LBRYWallet.py b/lbrynet/core/LBRYWallet.py index 99f4939fe..571f981d6 100644 --- a/lbrynet/core/LBRYWallet.py +++ b/lbrynet/core/LBRYWallet.py @@ -289,7 +289,7 @@ class LBRYWallet(object): d = self._do_send_many(payments_to_send) d.addCallback(lambda txid: log.debug("Sent transaction %s", txid)) return d - log.info("There were no payments to send") + log.debug("There were no payments to send") return defer.succeed(True) def get_stream_info_for_name(self, name): diff --git a/lbrynet/core/log_support.py b/lbrynet/core/log_support.py index 8ca5b2b9b..04a6fb42d 100644 --- a/lbrynet/core/log_support.py +++ b/lbrynet/core/log_support.py @@ -76,12 +76,16 @@ def disable_third_party_loggers(): def disable_noisy_loggers(): - logging.getLogger('lbrynet.dht').setLevel(logging.INFO) + logging.getLogger('BitcoinRPC').setLevel(logging.INFO) + logging.getLogger('lbrynet.analytics.api').setLevel(logging.INFO) logging.getLogger('lbrynet.core.client.ConnectionManager').setLevel(logging.INFO) logging.getLogger('lbrynet.core.client.BlobRequester').setLevel(logging.INFO) logging.getLogger('lbrynet.core.client.ClientProtocol').setLevel(logging.INFO) - logging.getLogger('lbrynet.analytics.api').setLevel(logging.INFO) - logging.getLogger('BitcoinRPC').setLevel(logging.INFO) + logging.getLogger('lbrynet.core.server.ServerRequestHandler').setLevel(logging.INFO) + logging.getLogger('lbrynet.core.server.ServerProtocol').setLevel(logging.INFO) + logging.getLogger('lbrynet.core.server.BlobAvailabilityHandler').setLevel(logging.INFO) + logging.getLogger('lbrynet.dht').setLevel(logging.INFO) + logging.getLogger('lbrynet.lbrynet_daemon.LBRYExchangeRateManager').setLevel(logging.INFO) @_log_decorator diff --git a/lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py b/lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py index 0af938954..22d0cb4a2 100644 --- a/lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py +++ b/lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py @@ -47,7 +47,7 @@ class MarketFeed(object): return defer.succeed(from_amount / (1.0 - self.fee)) def _save_price(self, price): - log.info("Saving price update %f for %s" % (price, self.market)) + log.debug("Saving price update %f for %s" % (price, self.market)) self.rate = ExchangeRate(self.market, price, int(time.time())) def _update_price(self): @@ -191,7 +191,7 @@ class DummyExchangeRateManager(object): feed.rate = ExchangeRate(feed.market, rates[feed.market]['spot'], rates[feed.market]['ts']) def convert_currency(self, from_currency, to_currency, amount): - log.info("Converting %f %s to %s" % (amount, from_currency, to_currency)) + log.debug("Converting %f %s to %s" % (amount, from_currency, to_currency)) for market in self.market_feeds: if market.rate.currency_pair == (from_currency, to_currency): return amount * market.rate.spot