forked from LBRYCommunity/lbry-sdk
use float instead of decimal for now
This commit is contained in:
parent
cced217e43
commit
aa1405887e
2 changed files with 11 additions and 6 deletions
|
@ -4,7 +4,6 @@ import sys
|
|||
import typing
|
||||
import logging
|
||||
import yaml
|
||||
import decimal
|
||||
from argparse import ArgumentParser
|
||||
from contextlib import contextmanager
|
||||
from appdirs import user_data_dir, user_config_dir
|
||||
|
@ -117,12 +116,18 @@ class Integer(Setting[int]):
|
|||
assert isinstance(val, int), \
|
||||
f"Setting '{self.name}' must be an integer."
|
||||
|
||||
def deserialize(self, value):
|
||||
return int(value)
|
||||
|
||||
|
||||
class Float(Setting[float]):
|
||||
def validate(self, val):
|
||||
assert isinstance(val, float), \
|
||||
f"Setting '{self.name}' must be a decimal."
|
||||
|
||||
def deserialize(self, value):
|
||||
return float(value)
|
||||
|
||||
|
||||
class Toggle(Setting[bool]):
|
||||
def validate(self, val):
|
||||
|
@ -169,8 +174,8 @@ class MaxKeyFee(Setting[dict]):
|
|||
def _parse_list(l):
|
||||
assert len(l) == 2, 'Max key fee is made up of two values: "AMOUNT CURRENCY".'
|
||||
try:
|
||||
amount = decimal.Decimal(l[0])
|
||||
except decimal.InvalidOperation:
|
||||
amount = float(l[0])
|
||||
except ValueError:
|
||||
raise AssertionError('First value in max key fee is a decimal: "AMOUNT CURRENCY"')
|
||||
currency = str(l[1]).upper()
|
||||
if currency not in CURRENCIES:
|
||||
|
@ -183,7 +188,7 @@ class MaxKeyFee(Setting[dict]):
|
|||
if isinstance(value, dict):
|
||||
return {
|
||||
'currency': value['currency'],
|
||||
'amount': decimal.Decimal(value['amount']),
|
||||
'amount': float(value['amount']),
|
||||
}
|
||||
if isinstance(value, str):
|
||||
value = value.split()
|
||||
|
|
|
@ -780,7 +780,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
--data_rate=<data_rate> : (float) 0.0001
|
||||
--download_timeout=<download_timeout> : (int) 180
|
||||
--peer_port=<peer_port> : (int) 3333
|
||||
--max_key_fee=<max_key_fee> : (dict) maximum key fee for downloads,
|
||||
--max_key_fee=<max_key_fee> : (str) maximum key fee for downloads,
|
||||
in the format: '<amount> <currency>'
|
||||
Supported currency symbols: LBC, USD, BTC
|
||||
--no_max_key_fee : (bool) Disable max key fee.
|
||||
|
@ -801,7 +801,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
(dict) Updated dictionary of daemon settings
|
||||
"""
|
||||
with self.conf.update_config() as c:
|
||||
for key, value in kwargs:
|
||||
for key, value in kwargs.items():
|
||||
attr: Setting = getattr(type(c), key)
|
||||
setattr(c, key, attr.deserialize(value))
|
||||
return self.jsonrpc_settings_get()
|
||||
|
|
Loading…
Reference in a new issue