mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 18:11:36 +01:00
37 lines
1.0 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|