mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-31 20:54:31 +01:00
Revert "Add thread limit for updating payment states for payment invoices in NBXplorerListener"
This reverts commit 5d9827fb60.
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
using BTCPayServer;
|
||||
using BTCPayServer.Events;
|
||||
using BTCPayServer.HostedServices;
|
||||
@@ -27,8 +26,6 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||
/// </summary>
|
||||
public class NBXplorerListener : IHostedService
|
||||
{
|
||||
private const int UpdatePaymentStatesMaxDegreeOfParallelism = 32;
|
||||
|
||||
readonly EventAggregator _Aggregator;
|
||||
private readonly PayJoinRepository _payJoinRepository;
|
||||
readonly ExplorerClientProvider _ExplorerClients;
|
||||
@@ -141,7 +138,9 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||
switch (newEvent)
|
||||
{
|
||||
case NBXplorer.Models.NewBlockEvent evt:
|
||||
await UpdatePaymentStatesForPendingInvoices(wallet);
|
||||
await Task.WhenAll((await _InvoiceRepository.GetPendingInvoices())
|
||||
.Select(invoiceId => UpdatePaymentStates(wallet, invoiceId))
|
||||
.ToArray());
|
||||
_Aggregator.Publish(new Events.NewBlockEvent() { CryptoCode = evt.CryptoCode });
|
||||
break;
|
||||
case NBXplorer.Models.NewTransactionEvent evt:
|
||||
@@ -207,27 +206,6 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdatePaymentStatesForPendingInvoices(BTCPayWallet wallet)
|
||||
{
|
||||
var pendingInvoices = await _InvoiceRepository.GetPendingInvoices();
|
||||
var actionBlock = new ActionBlock<string>(invoiceId => UpdatePaymentStates(wallet, invoiceId),
|
||||
new ExecutionDataflowBlockOptions
|
||||
{
|
||||
CancellationToken = _Cts.Token,
|
||||
EnsureOrdered = false,
|
||||
SingleProducerConstrained = true,
|
||||
MaxDegreeOfParallelism = UpdatePaymentStatesMaxDegreeOfParallelism
|
||||
});
|
||||
|
||||
foreach (var invoiceId in pendingInvoices)
|
||||
{
|
||||
await actionBlock.SendAsync(invoiceId);
|
||||
}
|
||||
|
||||
actionBlock.Complete();
|
||||
await actionBlock.Completion;
|
||||
}
|
||||
|
||||
async Task<InvoiceEntity> UpdatePaymentStates(BTCPayWallet wallet, string invoiceId)
|
||||
{
|
||||
var invoice = await _InvoiceRepository.GetInvoice(invoiceId, false);
|
||||
@@ -300,7 +278,7 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||
pj.CoinjoinTransactionHash == tx.TransactionHash)
|
||||
{
|
||||
// This payment is a coinjoin, so the value of
|
||||
// the payment output is different from the real value of the payment
|
||||
// the payment output is different from the real value of the payment
|
||||
paymentData.Value = pj.CoinjoinValue;
|
||||
payment.SetCryptoPaymentData(paymentData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user