1
0

exchange_rate: FxThread does not need network

This commit is contained in:
SomberNight
2023-03-28 15:45:15 +00:00
parent f4e66810e7
commit 512b63c424
3 changed files with 5 additions and 6 deletions

View File

@@ -771,7 +771,7 @@ class Commands:
kwargs['to_timestamp'] = time.mktime(end_date.timetuple())
if show_fiat:
from .exchange_rate import FxThread
fx = FxThread(self.config, None)
fx = FxThread(config=self.config)
kwargs['fx'] = fx
return json_normalize(wallet.get_detailed_history(**kwargs))

View File

@@ -395,7 +395,7 @@ class Daemon(Logger):
self.network = None
if not config.get('offline'):
self.network = Network(config, daemon=self)
self.fx = FxThread(config, self.network)
self.fx = FxThread(config=config)
self.gui_object = None
# path -> wallet; make sure path is standardized.
self._wallets = {} # type: Dict[str, Abstract_Wallet]

View File

@@ -519,10 +519,9 @@ def get_exchanges_by_ccy(history=True):
class FxThread(ThreadJob, EventListener):
def __init__(self, config: SimpleConfig, network: Optional[Network]):
def __init__(self, *, config: SimpleConfig):
ThreadJob.__init__(self)
self.config = config
self.network = network
self.register_callbacks()
self.ccy = self.get_currency()
self.history_used_spot = False
@@ -610,8 +609,8 @@ class FxThread(ThreadJob, EventListener):
self.on_quotes()
def trigger_update(self):
if self.network:
self.network.asyncio_loop.call_soon_threadsafe(self._trigger.set)
loop = util.get_asyncio_loop()
loop.call_soon_threadsafe(self._trigger.set)
def set_exchange(self, name):
class_ = globals().get(name) or globals().get(DEFAULT_EXCHANGE)