Skip to content

Commit 42b955b

Browse files
committed
paginated plot functions and types
1 parent 0af5354 commit 42b955b

File tree

7 files changed

+141
-5
lines changed

7 files changed

+141
-5
lines changed

src/chia-dotnet.tests/Factory.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace chia.dotnet.tests
99
internal static class Factory
1010
{
1111
// this is the ip address of the chia node
12-
private const string NodeHostAddress = "chiapas";
12+
private const string NodeHostAddress = "former";
1313

1414
public static HttpRpcClient CreateDirectRpcClientFromHardcodedLocation(int port, string endpointName)
1515
{
@@ -20,8 +20,8 @@ public static HttpRpcClient CreateDirectRpcClientFromHardcodedLocation(int port,
2020
//KeyPath = @"\\wsl$/Ubuntu-20.04/home/don/.chia/mainnet/config/ssl/full_node/private_full_node.key",
2121
//CertPath = @"C:\Users\dkack\.rchia\certs\chiapas\private_daemon.crt",
2222
//KeyPath = @"C:\Users\dkack\.rchia\certs\chiapas\private_daemon.key",
23-
CertPath = $@"C:\Users\dkack\.rchia\certs\chiapas\private_{endpointName}.crt",
24-
KeyPath = $@"C:\Users\dkack\.rchia\certs\chiapas\private_{endpointName}.key",
23+
CertPath = $@"C:\Users\dkack\.rchia\certs\{NodeHostAddress}\private_{endpointName}.crt",
24+
KeyPath = $@"C:\Users\dkack\.rchia\certs\{NodeHostAddress}\private_{endpointName}.key",
2525
//CertPath = @"C:\Users\dkack\.rchia\certs\chiapas\private_full_node.crt",
2626
//KeyPath = @"C:\Users\dkack\.rchia\certs\chiapas\private_full_node.key",
2727
};
@@ -43,8 +43,8 @@ public static WebSocketRpcClient CreateWebsocketClient()
4343
var endpoint = new EndpointInfo()
4444
{
4545
Uri = new Uri($"wss://{NodeHostAddress}:55400"),
46-
CertPath = @"C:\Users\dkack\.rchia\certs\chiapas\private_daemon.crt",
47-
KeyPath = @"C:\Users\dkack\.rchia\certs\chiapas\private_daemon.key",
46+
CertPath = $@"C:\Users\dkack\.rchia\certs\{NodeHostAddress}\private_daemon.crt",
47+
KeyPath = $@"C:\Users\dkack\.rchia\certs\{NodeHostAddress}\private_daemon.key",
4848
//CertPath = @"\\wsl$\Ubuntu-20.04\home\don\.chia\mainnet\config\ssl\daemon\private_daemon.crt",
4949
//KeyPath = @"\\wsl$\Ubuntu-20.04\home\don\.chia\mainnet\config\ssl\daemon\private_daemon.key",
5050
//CertPath = @"\\wsl.localhost\Ubuntu\home\don\.chia\mainnet\config\ssl\daemon\private_daemon.crt",

src/chia-dotnet.tests/FarmerProxyTests.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,50 @@ public async Task GetSignagePoints()
7878
Assert.IsNotNull(signagePoints);
7979
}
8080

81+
[TestMethod]
82+
public async Task GetHarvestersSummary()
83+
{
84+
using var cts = new CancellationTokenSource(15000);
85+
86+
var summaries = await _theFarmer.GetHarvestersSummary(cts.Token);
87+
88+
Assert.IsNotNull(summaries);
89+
}
90+
91+
[TestMethod]
92+
public async Task GetHarvesterPlotsValid()
93+
{
94+
using var cts = new CancellationTokenSource(15000);
95+
var summaries = await _theFarmer.GetHarvestersSummary(cts.Token);
96+
var nodeId = summaries.First().Connection.NodeId;
97+
var requestDatata = new PlotInfoRequestData()
98+
{
99+
NodeId = nodeId,
100+
PageSize = 10,
101+
};
102+
103+
var plotInfo = await _theFarmer.GetHarvesterPlotsValid(requestDatata, cts.Token);
104+
105+
Assert.IsNotNull(plotInfo);
106+
}
107+
108+
[TestMethod]
109+
public async Task GetHarvesterPlotsKeysMissing()
110+
{
111+
using var cts = new CancellationTokenSource(15000);
112+
var summaries = await _theFarmer.GetHarvestersSummary(cts.Token);
113+
var nodeId = summaries.First().Connection.NodeId;
114+
var requestDatata = new PlotPathRequestData()
115+
{
116+
NodeId = nodeId,
117+
PageSize = 10,
118+
};
119+
120+
var plotInfo = await _theFarmer.GetHarvesterPlotsKeysMissing(requestDatata, cts.Token);
121+
122+
Assert.IsNotNull(plotInfo);
123+
}
124+
81125
[TestMethod]
82126
public async Task GetSignagePoint()
83127
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace chia.dotnet
2+
{
3+
public record FilterItem
4+
{
5+
public string Key { get; init; } = string.Empty;
6+
public string? Value { get; init; }
7+
}
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections.Generic;
2+
3+
namespace chia.dotnet
4+
{
5+
public record PaginatedPlotRequest
6+
{
7+
public string NodeId { get; init; } = string.Empty;
8+
public int Page { get; init; }
9+
public int PageCount { get; init; }
10+
public int TotalCount { get; init; }
11+
public IEnumerable<PlotInfo> Plots { get; init; } = new List<PlotInfo>();
12+
}
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections.Generic;
2+
3+
namespace chia.dotnet
4+
{
5+
public record PlotInfoRequestData
6+
{
7+
public string NodeId { get; init; } = string.Empty;
8+
public int Page { get; init; }
9+
public int PageSize { get; init; }
10+
public IEnumerable<FilterItem> Filter { get; init; } = new List<FilterItem>();
11+
public string SortKey { get; init; } = "filename";
12+
public bool Reverse { get; init; }
13+
}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections.Generic;
2+
3+
namespace chia.dotnet
4+
{
5+
public record PlotPathRequestData
6+
{
7+
public string NodeId { get; init; } = string.Empty;
8+
public int Page { get; init; }
9+
public int PageSize { get; init; }
10+
public IEnumerable<string> Filter { get; init; } = new List<string>();
11+
public bool Reverse { get; init; }
12+
}
13+
}

src/chia-dotnet/FarmerProxy.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,50 @@ public async Task<IEnumerable<HarvesterSummary>> GetHarvestersSummary(Cancellati
179179
return await SendMessage<IEnumerable<HarvesterSummary>>("get_harvesters_summary", "harvesters", cancellationToken).ConfigureAwait(false);
180180
}
181181

182+
/// <summary>
183+
/// Get a paginated list of valid plots
184+
/// </summary>
185+
/// <param name="requestData">Info about the request</param>
186+
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
187+
/// <returns>A page of valid plots</returns>
188+
public async Task<PaginatedPlotRequest> GetHarvesterPlotsValid(PlotInfoRequestData requestData, CancellationToken cancellationToken = default)
189+
{
190+
return await SendMessage<PaginatedPlotRequest>("get_harvester_plots_valid", requestData, null, cancellationToken).ConfigureAwait(false);
191+
}
192+
193+
/// <summary>
194+
/// Get a paginated list of invalid plots
195+
/// <param name="requestData">Info about the request</param>
196+
/// </summary>
197+
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
198+
/// <returns>A page of invalid plots</returns>
199+
public async Task<PaginatedPlotRequest> GetHarvesterPlotsInvalid(PlotPathRequestData requestData, CancellationToken cancellationToken = default)
200+
{
201+
return await SendMessage<PaginatedPlotRequest>("get_harvester_plots_invalid", requestData, null, cancellationToken).ConfigureAwait(false);
202+
}
203+
204+
/// <summary>
205+
/// Get a paginated list of plots with missing keys
206+
/// </summary>
207+
/// <param name="requestData">Info about the request</param>
208+
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
209+
/// <returns>A page of plots with missing keys</returns>
210+
public async Task<PaginatedPlotRequest> GetHarvesterPlotsKeysMissing(PlotPathRequestData requestData, CancellationToken cancellationToken = default)
211+
{
212+
return await SendMessage<PaginatedPlotRequest>("get_harvester_plots_keys_missing", requestData, null, cancellationToken).ConfigureAwait(false);
213+
}
214+
215+
/// <summary>
216+
/// Get a paginated list of duplicate plots
217+
/// </summary>
218+
/// <param name="requestData">Info about the request</param>
219+
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
220+
/// <returns>A page of duplicate plots</returns>
221+
public async Task<PaginatedPlotRequest> GetHarvesterPlotsDuplicates(PlotPathRequestData requestData, CancellationToken cancellationToken = default)
222+
{
223+
return await SendMessage<PaginatedPlotRequest>("get_harvester_plots_duplicates", requestData, null, cancellationToken).ConfigureAwait(false);
224+
}
225+
182226
/// <summary>
183227
/// Get's the pool login link, if any
184228
/// </summary>

0 commit comments

Comments
 (0)