btcpayserver/BTCPayServer/Services/NBXSyncSummaryProvider.cs

51 lines
1.6 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Client.Models;
2020-07-28 22:48:51 +02:00
using BTCPayServer.HostedServices;
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";
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
}
2020-07-28 22:48:51 +02:00
}