Remove old float formatting

This commit is contained in:
Zestyr 2017-07-04 03:20:57 +02:00 committed by Jack Robison
parent cc7a3d3dcc
commit 2f2b27e872
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF
3 changed files with 4 additions and 22 deletions

View file

@ -17,7 +17,7 @@ at anytime.
*
### Fixed
*
* Fixed incorrect formatting of "amount" fields
*
### Deprecated

View file

@ -363,7 +363,7 @@ class SqliteStorage(MetaDataStorage):
" last_modified)"
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(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)
@rerun_if_locked
@ -376,7 +376,7 @@ class SqliteStorage(MetaDataStorage):
if certificate_id:
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:
log.warning("Certificate is not in cache")
elif certificate_result:

View file

@ -1338,8 +1338,7 @@ class Daemon(AuthJSONRPCServer):
claim_results = yield self.session.wallet.get_claim_by_outpoint(outpoint)
else:
raise Exception("Must specify either txid/nout, or claim_id")
result = format_json_out_amount_as_float(claim_results)
response = yield self._render_response(result)
response = yield self._render_response(claim_results)
defer.returnValue(response)
@AuthJSONRPCServer.auth_required
@ -1961,7 +1960,6 @@ class Daemon(AuthJSONRPCServer):
"""
d = self.session.wallet.get_name_claims()
d.addCallback(format_json_out_amount_as_float)
d.addCallback(lambda claims: self._render_response(claims))
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]
log.info("Downloading blob with rate manager: %s", 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