2021-05-19 06:07:28 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2020-11-17 13:46:23 +01:00
|
|
|
using BTCPayServer.Abstractions.Contracts;
|
2021-05-19 06:07:28 +02:00
|
|
|
using BTCPayServer.Client.Models;
|
2020-07-28 22:48:51 +02:00
|
|
|
using BTCPayServer.HostedServices;
|
2021-05-19 06:07:28 +02:00
|
|
|
using NBXplorer.Models;
|
2020-07-28 22:48:51 +02:00
|
|
|
|
|
|
|
namespace BTCPayServer.Services
|
|
|
|
{
|
|
|
|
public class NBXSyncSummaryProvider : ISyncSummaryProvider
|
|
|
|
{
|
|
|
|
private readonly NBXplorerDashboard _nbXplorerDashboard;
|
|
|
|
|
|
|
|
public NBXSyncSummaryProvider(NBXplorerDashboard nbXplorerDashboard)
|
|
|
|
{
|
|
|
|
_nbXplorerDashboard = nbXplorerDashboard;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool AllAvailable()
|
|
|
|
{
|
|
|
|
return _nbXplorerDashboard.IsFullySynched();
|
|
|
|
}
|
|
|
|
|
2020-11-06 08:41:03 +01:00
|
|
|
public string Partial { get; } = "Bitcoin/NBXSyncSummary";
|
2021-05-19 06:07:28 +02:00
|
|
|
public IEnumerable<ISyncStatus> GetStatuses()
|
|
|
|
{
|
|
|
|
return _nbXplorerDashboard.GetAll()
|
|
|
|
.Where(summary => summary.Network.ShowSyncSummary)
|
|
|
|
.Select(summary => new ServerInfoSyncStatusData2
|
|
|
|
{
|
|
|
|
CryptoCode = summary.Network.CryptoCode,
|
|
|
|
NodeInformation = summary.Status.BitcoinStatus is BitcoinStatus s ? new ServerInfoNodeData()
|
|
|
|
{
|
|
|
|
Headers = s.Headers,
|
|
|
|
Blocks = s.Blocks,
|
|
|
|
VerificationProgress = s.VerificationProgress
|
|
|
|
} : null,
|
|
|
|
ChainHeight = summary.Status.ChainHeight,
|
|
|
|
SyncHeight = summary.Status.SyncHeight
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public class ServerInfoSyncStatusData2: ServerInfoSyncStatusData, ISyncStatus
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2020-07-28 22:48:51 +02:00
|
|
|
}
|
2021-05-19 06:07:28 +02:00
|
|
|
|
|
|
|
|
2020-07-28 22:48:51 +02:00
|
|
|
}
|