Skip to content

Commit

Permalink
Merge pull request #135 from lbryio/lbrycrdwallet-updateclaim-fix
Browse files Browse the repository at this point in the history
LBRYcrdWallet update claim fix
  • Loading branch information
jackrobison committed Aug 22, 2016
2 parents 9c82689 + 128b32c commit 01eb79c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
50 changes: 25 additions & 25 deletions lbrynet/core/LBRYWallet.py
Expand Up @@ -289,7 +289,7 @@ def _send_payments(self):
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):
Expand Down Expand Up @@ -493,6 +493,29 @@ def get_history(self):
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)
Expand Down Expand Up @@ -989,7 +1012,7 @@ def _get_value_for_name_rpc(self, name):
@_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):
Expand Down Expand Up @@ -1314,29 +1337,6 @@ def _get_history(self):
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)
Expand Down
3 changes: 2 additions & 1 deletion lbrynet/core/client/ConnectionManager.py
Expand Up @@ -172,7 +172,8 @@ def get_new_peers(request_creators):
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:
Expand Down
9 changes: 7 additions & 2 deletions lbrynet/core/log_support.py
Expand Up @@ -76,11 +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('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
Expand Down
4 changes: 2 additions & 2 deletions lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py
Expand Up @@ -47,7 +47,7 @@ def _subtract_fee(self, from_amount):
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):
Expand Down Expand Up @@ -191,7 +191,7 @@ def __init__(self, rates):
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
Expand Down

0 comments on commit 01eb79c

Please sign in to comment.