mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 10:40:29 +01:00
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using System;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Controllers;
|
|
using BTCPayServer.Logging;
|
|
using BTCPayServer.Events;
|
|
|
|
namespace BTCPayServer
|
|
{
|
|
public class Initializer
|
|
{
|
|
EventAggregator _Aggregator;
|
|
CallbackController _CallbackController;
|
|
public Initializer(EventAggregator aggregator,
|
|
CallbackController callbackController
|
|
)
|
|
{
|
|
_Aggregator = aggregator;
|
|
_CallbackController = callbackController;
|
|
}
|
|
public void Init()
|
|
{
|
|
_Aggregator.Subscribe<NBXplorerStateChangedEvent>(async (s, evt) =>
|
|
{
|
|
if (evt.NewState == NBXplorerState.Ready)
|
|
{
|
|
s.Unsubscribe();
|
|
try
|
|
{
|
|
var callback = await _CallbackController.GetCallbackBlockUriAsync();
|
|
await _CallbackController.RegisterCallbackBlockUriAsync(callback);
|
|
Logs.PayServer.LogInformation($"Registering block callback to " + callback);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logs.PayServer.LogError(ex, "Could not register block callback");
|
|
s.Resubscribe();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|