Browse Source

exchange_rate: FxThread does not need network

master
SomberNight 3 years ago
parent
commit
512b63c424
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/commands.py
  2. 2
      electrum/daemon.py
  3. 7
      electrum/exchange_rate.py

2
electrum/commands.py

@ -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))

2
electrum/daemon.py

@ -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]

7
electrum/exchange_rate.py

@ -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)

Loading…
Cancel
Save