forked from LBRYCommunity/lbry-sdk
Merge branch 'fix_resolve_formatting'
This commit is contained in:
commit
15e44b0c9d
3 changed files with 4 additions and 22 deletions
|
@ -17,7 +17,7 @@ at anytime.
|
||||||
*
|
*
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
*
|
* Fixed incorrect formatting of "amount" fields
|
||||||
*
|
*
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
@ -363,7 +363,7 @@ class SqliteStorage(MetaDataStorage):
|
||||||
" last_modified)"
|
" last_modified)"
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
(claim_sequence, claim_id, claim_address, height, amount,
|
(claim_sequence, claim_id, claim_address, height, amount,
|
||||||
supports, serialized, channel_name, signature_is_valid, now))
|
supports, serialized, channel_name, signature_is_valid, now))
|
||||||
defer.returnValue(None)
|
defer.returnValue(None)
|
||||||
|
|
||||||
@rerun_if_locked
|
@rerun_if_locked
|
||||||
|
@ -376,7 +376,7 @@ class SqliteStorage(MetaDataStorage):
|
||||||
|
|
||||||
if certificate_id:
|
if certificate_id:
|
||||||
certificate_result = yield self.db.runQuery("SELECT row_id FROM claim_cache "
|
certificate_result = yield self.db.runQuery("SELECT row_id FROM claim_cache "
|
||||||
"WHERE claim_id=?", (certificate_id, ))
|
"WHERE claim_id=?", (certificate_id, ))
|
||||||
if certificate_id is not None and certificate_result is None:
|
if certificate_id is not None and certificate_result is None:
|
||||||
log.warning("Certificate is not in cache")
|
log.warning("Certificate is not in cache")
|
||||||
elif certificate_result:
|
elif certificate_result:
|
||||||
|
|
|
@ -1338,8 +1338,7 @@ class Daemon(AuthJSONRPCServer):
|
||||||
claim_results = yield self.session.wallet.get_claim_by_outpoint(outpoint)
|
claim_results = yield self.session.wallet.get_claim_by_outpoint(outpoint)
|
||||||
else:
|
else:
|
||||||
raise Exception("Must specify either txid/nout, or claim_id")
|
raise Exception("Must specify either txid/nout, or claim_id")
|
||||||
result = format_json_out_amount_as_float(claim_results)
|
response = yield self._render_response(claim_results)
|
||||||
response = yield self._render_response(result)
|
|
||||||
defer.returnValue(response)
|
defer.returnValue(response)
|
||||||
|
|
||||||
@AuthJSONRPCServer.auth_required
|
@AuthJSONRPCServer.auth_required
|
||||||
|
@ -1961,7 +1960,6 @@ class Daemon(AuthJSONRPCServer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
d = self.session.wallet.get_name_claims()
|
d = self.session.wallet.get_name_claims()
|
||||||
d.addCallback(format_json_out_amount_as_float)
|
|
||||||
d.addCallback(lambda claims: self._render_response(claims))
|
d.addCallback(lambda claims: self._render_response(claims))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -2614,19 +2612,3 @@ def get_blob_payment_rate_manager(session, payment_rate_manager=None):
|
||||||
payment_rate_manager = rate_managers[payment_rate_manager]
|
payment_rate_manager = rate_managers[payment_rate_manager]
|
||||||
log.info("Downloading blob with rate manager: %s", payment_rate_manager)
|
log.info("Downloading blob with rate manager: %s", payment_rate_manager)
|
||||||
return payment_rate_manager or session.payment_rate_manager
|
return payment_rate_manager or session.payment_rate_manager
|
||||||
|
|
||||||
|
|
||||||
# lbryum returns json loadeable object with amounts as decimal encoded string,
|
|
||||||
# convert them into floats for the daemon
|
|
||||||
# TODO: daemon should also use decimal encoded string
|
|
||||||
def format_json_out_amount_as_float(obj):
|
|
||||||
if isinstance(obj, dict):
|
|
||||||
for k, v in obj.iteritems():
|
|
||||||
if k == 'amount' or k == 'effective_amount':
|
|
||||||
obj[k] = float(obj[k])
|
|
||||||
if isinstance(v, (dict, list)):
|
|
||||||
obj[k] = format_json_out_amount_as_float(v)
|
|
||||||
|
|
||||||
elif isinstance(obj, list):
|
|
||||||
obj = [format_json_out_amount_as_float(o) for o in obj]
|
|
||||||
return obj
|
|
||||||
|
|
Loading…
Reference in a new issue