1
0

exchange_rate: more robust spot price against temporary network issues

We poll the fx rate provider every 2.5 minutes (unchanged).
Previously if there was any error during a tick, there was no fx rate
available in the client until the next tick.
Now, instead, we keep the last rates received with a 10 minute expiry.

One potential drawback is that previously there was instant feedback
to the user when e.g. changing proxy settings, and this is no longer
the case. E.g. consider a provider that bans Tor exit nodes. If a user
enables using a Tor proxy in the network settings, the fxrate used to
disappear immediately - but now the cached rate would still be
available.
This commit is contained in:
SomberNight
2022-08-24 13:00:41 +00:00
parent 757ec53ea2
commit 03b514863e
2 changed files with 28 additions and 16 deletions

View File

@@ -89,7 +89,8 @@ class TestWalletStorage(WalletTestCase):
class FakeExchange(ExchangeBase):
def __init__(self, rate):
super().__init__(lambda self: None, lambda self: None)
self.quotes = {'TEST': rate}
self._quotes = {'TEST': rate}
self._quotes_timestamp = float("inf") # spot price from the far future never becomes stale :P
class FakeFxThread:
def __init__(self, exchange):