btcpayserver/BTCPayServer/HostedServices/DelayedTransactionBroadcasterHostedService.cs
2021-11-23 13:55:34 +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(Cancellation);
await Task.Delay(PollInternal, Cancellation);
}
}
}
}