btcpayserver/BTCPayServer/HostedServices/DelayedTransactionBroadcasterHostedService.cs
2023-04-26 18:09:56 +09:00

37 lines
1.0 KiB
C#

using System;
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, Logs logs) : base(logs)
{
_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(CancellationToken);
await Task.Delay(PollInternal, CancellationToken);
}
}
}
}