mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 10:30:47 +01:00
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
|
using Microsoft.Extensions.Logging;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using BTCPayServer.Logging;
|
|||
|
using BTCPayServer.Services;
|
|||
|
|
|||
|
namespace BTCPayServer.HostedServices
|
|||
|
{
|
|||
|
public class DelayedTransactionBroadcasterHostedService : BaseAsyncService
|
|||
|
{
|
|||
|
private readonly DelayedTransactionBroadcaster _transactionBroadcaster;
|
|||
|
|
|||
|
public DelayedTransactionBroadcasterHostedService(DelayedTransactionBroadcaster transactionBroadcaster)
|
|||
|
{
|
|||
|
_transactionBroadcaster = transactionBroadcaster;
|
|||
|
}
|
|||
|
|
|||
|
internal override Task[] InitializeTasks()
|
|||
|
{
|
|||
|
return new Task[]
|
|||
|
{
|
|||
|
CreateLoopTask(Rebroadcast)
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public TimeSpan PollInternal { get; set; } = TimeSpan.FromMinutes(1.0);
|
|||
|
|
|||
|
async Task Rebroadcast()
|
|||
|
{
|
|||
|
while (true)
|
|||
|
{
|
|||
|
await _transactionBroadcaster.ProcessAll(Cancellation);
|
|||
|
await Task.Delay(PollInternal, Cancellation);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|