Merge pull request #614 from lbryio/fix_stream_cost_est

Fix stream_cost_estimate
This commit is contained in:
Umpei Kay Kurokawa 2017-04-19 18:24:37 -04:00 committed by GitHub
commit cb8730e696
2 changed files with 5 additions and 3 deletions

View file

@ -19,7 +19,7 @@ at anytime.
* *
### Fixed ### Fixed
* * fix stream_cost_estimate throwing exception on non decodeable claims
* *
* *

View file

@ -889,12 +889,13 @@ class Daemon(AuthJSONRPCServer):
""" """
try: try:
claim_response = yield self.session.wallet.resolve_uri(uri) claim_response = yield self.session.wallet.resolve_uri(uri)
#TODO: fix me, this is a hack
except Exception: except Exception:
claim_response = None claim_response = None
result = None result = None
if claim_response and 'claim' in claim_response: if claim_response and 'claim' in claim_response:
if 'value' in claim_response['claim']: if 'value' in claim_response['claim'] and claim_response['claim']['value'] is not None:
claim_value = ClaimDict.load_dict(claim_response['claim']['value']) claim_value = ClaimDict.load_dict(claim_response['claim']['value'])
cost = yield self._get_est_cost_from_metadata(claim_value, uri) cost = yield self._get_est_cost_from_metadata(claim_value, uri)
result = round(cost, 5) result = round(cost, 5)
@ -1719,7 +1720,8 @@ class Daemon(AuthJSONRPCServer):
'size' (optional): (int) stream size, in bytes. if provided an sd blob 'size' (optional): (int) stream size, in bytes. if provided an sd blob
won't be downloaded. won't be downloaded.
Returns: Returns:
(float) Estimated cost in lbry credits (float) Estimated cost in lbry credits, returns None if uri is not
resolveable
""" """
cost = yield self.get_est_cost(uri, size) cost = yield self.get_est_cost(uri, size)
defer.returnValue(cost) defer.returnValue(cost)