nicolas.dorier 2018-01-18 18:53:11 +09:00
parent 4b7b6c6327
commit 39d47e33f6
2 changed files with 9 additions and 10 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<Version>1.0.1.6</Version>
<Version>1.0.1.7</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Build\dockerfiles\**" />

View File

@ -456,10 +456,8 @@ namespace BTCPayServer.HostedServices
{
try
{
Logs.PayServer.LogInformation($"POLL");
foreach (var pending in await _InvoiceRepository.GetPendingInvoices())
{
Logs.PayServer.LogInformation($"POLL: {pending}");
_WatchRequests.Add(pending);
}
await Task.Delay(PollInterval, cancellation);
@ -483,24 +481,25 @@ namespace BTCPayServer.HostedServices
{
foreach (var item in _WatchRequests.GetConsumingEnumerable(cancellation))
{
bool added = false;
var task = executing.GetOrAdd(item, async i =>
{
try
{
Logs.PayServer.LogInformation($"Updating {i}");
added = true;
await UpdateInvoice(i, cancellation);
}
catch (Exception ex) when (!cancellation.IsCancellationRequested)
{
Logs.PayServer.LogCritical(ex, $"Error in the InvoiceWatcher loop (Invoice {i})");
await Task.Delay(2000, cancellation);
}
finally {
Logs.PayServer.LogInformation($"Updated {i}");
if(!executing.TryRemove(i, out Task useless))
Logs.PayServer.LogInformation($"NOT REMOVED");
}
});
if (!added && task.Status == TaskStatus.RanToCompletion)
{
executing.TryRemove(item, out Task t);
_WatchRequests.Add(item);
}
}
}
catch when (cancellation.IsCancellationRequested)