2020-06-28 21:44:35 -05:00
|
|
|
using System;
|
2020-03-30 00:28:22 +09:00
|
|
|
using System.Threading.Tasks;
|
2021-11-22 17:16:08 +09:00
|
|
|
using BTCPayServer.Logging;
|
2020-03-30 00:28:22 +09:00
|
|
|
using BTCPayServer.Services;
|
|
|
|
|
|
|
|
namespace BTCPayServer.HostedServices
|
|
|
|
{
|
|
|
|
public class DelayedTransactionBroadcasterHostedService : BaseAsyncService
|
|
|
|
{
|
|
|
|
private readonly DelayedTransactionBroadcaster _transactionBroadcaster;
|
|
|
|
|
2021-11-22 17:16:08 +09:00
|
|
|
public DelayedTransactionBroadcasterHostedService(DelayedTransactionBroadcaster transactionBroadcaster, Logs logs) : base(logs)
|
2020-03-30 00:28:22 +09:00
|
|
|
{
|
|
|
|
_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)
|
|
|
|
{
|
2023-04-26 18:09:56 +09:00
|
|
|
await _transactionBroadcaster.ProcessAll(CancellationToken);
|
|
|
|
await Task.Delay(PollInternal, CancellationToken);
|
2020-03-30 00:28:22 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|