From 8e3f7ea68d77293c0751e4eb70308b1cd06d215d Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sun, 18 Feb 2018 02:40:53 +0900 Subject: [PATCH] do not block next invoices if one invoice fail processing --- BTCPayServer/HostedServices/InvoiceWatcher.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/HostedServices/InvoiceWatcher.cs b/BTCPayServer/HostedServices/InvoiceWatcher.cs index da2d5f787..22b03991d 100644 --- a/BTCPayServer/HostedServices/InvoiceWatcher.cs +++ b/BTCPayServer/HostedServices/InvoiceWatcher.cs @@ -55,7 +55,7 @@ namespace BTCPayServer.HostedServices _EventAggregator = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator)); _NetworkProvider = networkProvider; } - CompositeDisposable leases = new CompositeDisposable(); + CompositeDisposable leases = new CompositeDisposable(); private async Task UpdateInvoice(UpdateInvoiceContext context) @@ -110,7 +110,7 @@ namespace BTCPayServer.HostedServices if (invoice.Status == "paid") { - var transactions = payments.Where(p => p.GetCryptoPaymentData().PaymentConfirmed(p, invoice.SpeedPolicy, network)); + var transactions = payments.Where(p => p.GetCryptoPaymentData().PaymentConfirmed(p, invoice.SpeedPolicy, network)); var totalConfirmed = transactions.Select(t => t.GetValue(cryptoDataAll, cryptoData.CryptoCode)).Sum(); @@ -205,7 +205,7 @@ namespace BTCPayServer.HostedServices leases.Add(_EventAggregator.Subscribe(b => { - Watch(b.InvoiceId); + Watch(b.InvoiceId); })); leases.Add(_EventAggregator.Subscribe(async b => { @@ -279,7 +279,11 @@ namespace BTCPayServer.HostedServices catch (Exception ex) { Logs.PayServer.LogError(ex, "Unhandled error on watching invoice " + invoiceId); - await Task.Delay(10000, cancellation); +#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + Task.Delay(10000, cancellation) + .ContinueWith(t => _WatchRequests.Add(invoiceId), TaskScheduler.Default); +#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + break; } } }