mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Refactor server info data structure
This commit is contained in:
parent
501a21b89e
commit
1d092a15fb
@ -4,11 +4,6 @@ namespace BTCPayServer.Client.Models
|
||||
{
|
||||
public class ServerInfoData
|
||||
{
|
||||
/// <summary>
|
||||
/// detailed status information
|
||||
/// </summary>
|
||||
public ServerInfoStatusData Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the BTCPay Server version
|
||||
/// </summary>
|
||||
@ -23,15 +18,12 @@ namespace BTCPayServer.Client.Models
|
||||
/// the payment methods this server supports
|
||||
/// </summary>
|
||||
public IEnumerable<string> SupportedPaymentMethods { get; set; }
|
||||
}
|
||||
|
||||
public class ServerInfoStatusData
|
||||
{
|
||||
/// <summary>
|
||||
/// are all chains fully synched
|
||||
/// </summary>
|
||||
public bool FullySynched { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// detailed sync information per chain
|
||||
/// </summary>
|
||||
@ -41,7 +33,15 @@ namespace BTCPayServer.Client.Models
|
||||
public class ServerInfoSyncStatusData
|
||||
{
|
||||
public string CryptoCode { get; set; }
|
||||
public int BlockHeaders { get; set; }
|
||||
public float Progress { get; set; }
|
||||
public int ChainHeight { get; set; }
|
||||
public int? SyncHeight { get; set; }
|
||||
public ServerInfoNodeData NodeInformation { get; set; }
|
||||
}
|
||||
|
||||
public class ServerInfoNodeData
|
||||
{
|
||||
public int Headers { get; set; }
|
||||
public int Blocks { get; set; }
|
||||
public double VerificationProgress { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -345,12 +345,11 @@ namespace BTCPayServer.Tests
|
||||
Assert.NotNull(serverInfoData);
|
||||
Assert.NotNull(serverInfoData.Version);
|
||||
Assert.NotNull(serverInfoData.Onion);
|
||||
Assert.NotNull(serverInfoData.Status);
|
||||
Assert.True(serverInfoData.Status.FullySynched);
|
||||
Assert.True(serverInfoData.FullySynched);
|
||||
Assert.Contains("BTC", serverInfoData.SupportedPaymentMethods);
|
||||
Assert.Contains("BTC_LightningLike", serverInfoData.SupportedPaymentMethods);
|
||||
Assert.NotNull(serverInfoData.Status.SyncStatus);
|
||||
Assert.Single(serverInfoData.Status.SyncStatus.Select(s => s.CryptoCode == "BTC"));
|
||||
Assert.NotNull(serverInfoData.SyncStatus);
|
||||
Assert.Single(serverInfoData.SyncStatus.Select(s => s.CryptoCode == "BTC"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,7 +427,7 @@ namespace BTCPayServer.Tests
|
||||
|
||||
[Fact(Timeout = TestTimeout)]
|
||||
[Trait("Fast", "Fast")]
|
||||
public async Task DecimalStringJsonConverterTests()
|
||||
public void DecimalStringJsonConverterTests()
|
||||
{
|
||||
JsonReader Get(string val)
|
||||
{
|
||||
|
@ -223,5 +223,5 @@
|
||||
<_ContentIncludedByDefault Remove="Views\Authorization\Authorize.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ProjectExtensions><VisualStudio><UserProperties wwwroot_4swagger_4v1_4swagger_1template_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" /></VisualStudio></ProjectExtensions>
|
||||
<ProjectExtensions><VisualStudio><UserProperties wwwroot_4swagger_4v1_4swagger_1template_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" wwwroot_4swagger_4v1_4swagger_1template_1serverinfo_1json__JsonSchema="https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v3.0/schema.json" /></VisualStudio></ProjectExtensions>
|
||||
</Project>
|
||||
|
@ -10,6 +10,7 @@ using BTCPayServer.Services.Stores;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NBXplorer.Models;
|
||||
|
||||
namespace BTCPayServer.Controllers.GreenField
|
||||
{
|
||||
@ -52,17 +53,19 @@ namespace BTCPayServer.Controllers.GreenField
|
||||
.Select(summary => new ServerInfoSyncStatusData
|
||||
{
|
||||
CryptoCode = summary.Network.CryptoCode,
|
||||
BlockHeaders = summary.Status.ChainHeight,
|
||||
Progress = summary.Status.SyncHeight.GetValueOrDefault(0) / (float)summary.Status.ChainHeight
|
||||
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
|
||||
});
|
||||
ServerInfoStatusData status = new ServerInfoStatusData
|
||||
{
|
||||
FullySynched = _dashBoard.IsFullySynched(),
|
||||
SyncStatus = syncStatus
|
||||
};
|
||||
ServerInfoData model = new ServerInfoData
|
||||
{
|
||||
Status = status,
|
||||
FullySynched = _dashBoard.IsFullySynched(),
|
||||
SyncStatus = syncStatus,
|
||||
Onion = _env.OnionUrl,
|
||||
Version = _env.Version,
|
||||
SupportedPaymentMethods = supportedPaymentMethods
|
||||
|
@ -34,9 +34,6 @@
|
||||
"ApplicationServerInfoData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"$ref": "#/components/schemas/ApplicationServerInfoStatusData"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"description": "BTCPay Server version"
|
||||
@ -51,13 +48,7 @@
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ApplicationServerInfoStatusData": {
|
||||
"type": "object",
|
||||
"description": "Detailed sync status",
|
||||
"properties": {
|
||||
},
|
||||
"fullySynched": {
|
||||
"type": "boolean",
|
||||
"description": "True if the instance is fully synchronized, according to NBXplorer"
|
||||
@ -70,22 +61,48 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ApplicationServerInfoNodeStatusData": {
|
||||
"type": "object",
|
||||
"nullable": true,
|
||||
"description": "Detailed sync status of the internal full node",
|
||||
"properties": {
|
||||
"headers": {
|
||||
"type": "integer",
|
||||
"description": "The height of the chain of header of the internal full node"
|
||||
},
|
||||
"blocks": {
|
||||
"type": "integer",
|
||||
"description": "The height of the latest validated block of the internal full node"
|
||||
},
|
||||
"verificationProgress": {
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"minimum": 0.0,
|
||||
"maximum": 1.0,
|
||||
"description": "The current synchronization progress"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ApplicationServerInfoSyncStatusData": {
|
||||
"type": "object",
|
||||
"description": "Detailed sync status",
|
||||
"properties": {
|
||||
"cryptoCode": {
|
||||
"type": "string",
|
||||
"description": "True if the instance is fully synchronized, according to NBXplorer"
|
||||
"description": "The CryptoCode of the crypto currency (eg. BTC)"
|
||||
},
|
||||
"blockHeaders": {
|
||||
"nodeInformation": {
|
||||
"$ref": "#/components/schemas/ApplicationServerInfoNodeStatusData"
|
||||
},
|
||||
"chainHeight": {
|
||||
"type": "integer",
|
||||
"description": "True if the instance is fully synchronized, according to NBXplorer"
|
||||
"description": "The height of the chain of header of the internal indexer"
|
||||
},
|
||||
"progress": {
|
||||
"syncHeight": {
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"description": "True if the instance is fully synchronized, according to NBXplorer"
|
||||
"format": "integer",
|
||||
"nullable": true,
|
||||
"description": "The height of the latest indexed block of the internal indexer"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user