mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Do not crash if can't load rate cache
This commit is contained in:
parent
143c909812
commit
c03dc48fe9
@ -115,20 +115,24 @@ namespace BTCPayServer.HostedServices
|
||||
|
||||
private async Task TryLoadRateCache()
|
||||
{
|
||||
var cache = await _SettingsRepository.GetSettingAsync<ExchangeRatesCache>();
|
||||
if (cache != null)
|
||||
try
|
||||
{
|
||||
_LastCacheDate = cache.Created;
|
||||
var stateByExchange = cache.States.ToDictionary(o => o.ExchangeName);
|
||||
foreach (var provider in _RateProviderFactory.Providers)
|
||||
var cache = await _SettingsRepository.GetSettingAsync<ExchangeRatesCache>();
|
||||
if (cache != null)
|
||||
{
|
||||
if (stateByExchange.TryGetValue(provider.Key, out var state) &&
|
||||
provider.Value is BackgroundFetcherRateProvider fetcher)
|
||||
_LastCacheDate = cache.Created;
|
||||
var stateByExchange = cache.States.ToDictionary(o => o.ExchangeName);
|
||||
foreach (var provider in _RateProviderFactory.Providers)
|
||||
{
|
||||
fetcher.LoadState(state);
|
||||
if (stateByExchange.TryGetValue(provider.Key, out var state) &&
|
||||
provider.Value is BackgroundFetcherRateProvider fetcher)
|
||||
{
|
||||
fetcher.LoadState(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
DateTimeOffset? _LastCacheDate;
|
||||
|
@ -1,5 +1,5 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>1.0.3.157</Version>
|
||||
<Version>1.0.3.158</Version>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user