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