-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
95 lines (80 loc) · 2.99 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using Microsoft.Extensions.Configuration;
internal class Program
{
private static async Task Main(string[] args)
{
var algo = string.Empty;
if (args.Length != 0)
{
algo = args[0].ToUpperInvariant();
}
if (!string.IsNullOrEmpty(algo))
{
Console.WriteLine($"Selected coin: {algo}");
if (!new string[] { "HNS", "SC" }.Contains(algo))
{
Console.WriteLine("Coin invalid. Toggling algos");
algo = "toggle";
}
else
{
if (algo == "SC")
{
algo = "blake2b(SC)";
}
if (algo == "HNS")
{
algo = "blake2bsha3(HNS)";
}
Console.WriteLine($"Switching to: {algo}");
}
}
IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json", false, true);
IConfigurationRoot root = builder.Build();
var configuration = builder.Build();
var appSettings = new AppSettings();
configuration.Bind(appSettings);
foreach (var miner in appSettings.Miners)
{
await SwitchAlgo(miner, algo);
Thread.Sleep(appSettings.SwitchLag);
}
}
private static async Task SwitchAlgo(Miner miner, string algo)
{
var client = new GoldshellMcbClient($"http://{miner.Ip}/", miner.Username, miner.Password);
var algoResponse = await client.GetAlgo();
var poolsResponse = await client.GetPools();
if (algoResponse == default(AlgoSettingResponse))
{
return;
}
var currentAlgo = algoResponse.Algos.First(a => a.Id == algoResponse.SelectedAlgo).Name;
if ((algo == "toggle" || algo == "blake2b(SC)") && currentAlgo == "blake2bsha3(HNS)")
{
foreach (var pool in poolsResponse)
{
await client.DelPool(new DelPoolRequest(pool));
}
await client.AddPool(new AddPoolRequest(miner.Pools.First(p => p.Algo.StartsWith("blake2b(SC)"))));
await client.SetAlgo("blake2b(SC)", algoResponse);
}
else if ((algo == "toggle" || algo == "blake2bsha3(HNS)") && currentAlgo == "blake2b(SC)")
{
foreach (var pool in poolsResponse)
{
await client.DelPool(new DelPoolRequest(pool));
}
await client.AddPool(new AddPoolRequest(miner.Pools.First(p => p.Algo.StartsWith("blake2bsha3(HNS)"))));
await client.SetAlgo("blake2bsha3(HNS)", algoResponse);
}
else
{
var curData = await client.GetHashrate();
foreach (var d in curData.Data)
{
Console.WriteLine($"{miner.Ip}[{d.Id}]: {d.Hashrate / 1000} GH/s");
}
}
}
}