Skip to content

Commit 005a8f7

Browse files
Configuration for algo api id to avoid hard coding.
1 parent 8703c9d commit 005a8f7

14 files changed

Lines changed: 40 additions & 32 deletions

MinerControl/MainWindow.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MinerControl/MinerControl.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
{ "name": "scryptn", display: "Scrypt-N", "hashrate": 253, "power": 60, "aparam1": "c:\\windows\\system32", "aparam2": "cmd.exe", "aparam3": "/c test-run.bat -a scryptn -batch" },
3030
{ "name": "keccak", display: "Keccak", "hashrate": 34000, "power": 50, "aparam1": "", "aparam2": "TestMiner.exe", "aparam3": "-a keccak" },
3131
{ "name": "qubit", display: "Qubit", "hashrate": 7500, "power": 50, "aparam1": "", "aparam2": "TestMiner.exe", "aparam3": "-a qubit" },
32+
{ "name": "lyra2", display: "Lyra2RE", "hashrate": 1216, "power": 50, "aparam1": "", "aparam2": "TestMiner.exe", "aparam3": "-a lyra2re" },
3233
{ "name": "sha256", display: "SHA256", "hashrate": 10000, "power": 50, "aparam1": "c:\\windows\\system32", "aparam2": "cmd.exe", "aparam3": "/c test-run.bat -a sha256 -batch" }
3334
],
3435
"nicehash": {
@@ -46,6 +47,7 @@
4647
{ "algo": "keccak", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3338 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
4748
{ "algo": "nist5", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3340 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
4849
{ "algo": "neoscrypt", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3341 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
50+
{ "algo": "lyra2", "priceid": "9", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3342 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
4951
{ "algo": "sha256", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3332 -u _ACCOUNT_._WORKER_ _SPARAM2_", "usewindow": true }
5052
]
5153
},
@@ -62,6 +64,7 @@
6264
{ "algo": "scryptn", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3335 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
6365
{ "algo": "keccak", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3338 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
6466
{ "algo": "nist5", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3340 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
67+
{ "algo": "lyra2", "priceid": "9", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3342 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
6568
{ "algo": "neoscrypt", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3341 -u _ACCOUNT_._WORKER_ _SPARAM2_" }
6669
]
6770
},
@@ -92,6 +95,7 @@
9295
{ "algo": "x15", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3733 _ACCOUNT_ _SPARAM2_" },
9396
{ "algo": "quark", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:4033 _ACCOUNT_ _SPARAM2_" },
9497
{ "algo": "nist5", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3833 _ACCOUNT_ _SPARAM2_" },
98+
{ "algo": "lyra2", "priceid": "lyra2", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:4433 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
9599
{ "algo": "scrypt", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3433 _ACCOUNT_ _SPARAM2_" }
96100
]
97101
},

MinerControl/PriceEntries/NiceHashPriceEntry.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ namespace MinerControl.PriceEntries
77
{
88
public class NiceHashPriceEntry : PriceEntryBase
99
{
10-
public int AlgorithmId { get; set; }
11-
1210
public override decimal Fees
1311
{
1412
get { return Earn * 0.02m; }

MinerControl/PriceEntries/PriceEntryBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public PriceEntryBase()
1616
public MiningEngine MiningEngine { get; set; }
1717
public int Id { get; set; }
1818
public IService ServiceEntry { get; set; }
19+
public string PriceId { get; set; }
1920
public string AlgoName { get; set; }
2021
public string Name { get; set; }
2122
public bool UseWindow { get; set; }

MinerControl/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.5.6.0")]
36-
[assembly: AssemblyFileVersion("1.5.6.0")]
35+
[assembly: AssemblyVersion("1.6.0.0")]
36+
[assembly: AssemblyFileVersion("1.6.0.0")]

MinerControl/Services/HamsterPoolService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override void Initialize(IDictionary<string, object> data)
4040
foreach (var rawitem in items)
4141
{
4242
var item = rawitem as Dictionary<string, object>;
43-
var entry = GetEntry(item);
43+
var entry = CreateEntry(item);
4444
entry.Donation = _donation;
4545

4646
Add(entry);
@@ -64,7 +64,7 @@ private void ProcessPrices(object jsonData)
6464
var algo = key.ToLower();
6565
var price = data[key].ExtractDecimal();
6666

67-
var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == GetAlgoName(algo));
67+
var entry = GetEntry(algo);
6868
if (entry == null) continue;
6969

7070
entry.Price = price * 1000;
@@ -87,7 +87,7 @@ private void ProcessBalances(object jsonData)
8787
var algo = key.ToLower();
8888
var balance = data[key].ExtractDecimal();
8989

90-
var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == GetAlgoName(algo));
90+
var entry = GetEntry(algo);
9191
if (entry == null) continue;
9292

9393
entry.Balance = balance;

MinerControl/Services/LtcRabbitService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public override void Initialize(IDictionary<string, object> data)
4949
foreach (var rawitem in items)
5050
{
5151
var item = rawitem as Dictionary<string, object>;
52-
var entry = GetEntry(item);
52+
var entry = CreateEntry(item);
5353

5454
Add(entry);
5555
}
@@ -76,7 +76,7 @@ private void ProcessPrices(object jsonData)
7676
var item = rawitem as Dictionary<string, object>;
7777
var algo = key.ToLower();
7878

79-
var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == algo);
79+
var entry = GetEntry(algo);
8080
if (entry == null) continue;
8181

8282
entry.Price = item["btc_mh"].ExtractDecimal() * 1000;
@@ -98,14 +98,14 @@ private void ProcessBalances(object jsonData)
9898
var user = getappdata["user"] as Dictionary<string, object>;
9999
Balance = user["balance_btc"].ExtractDecimal();
100100

101-
var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == "x11");
101+
var entry = GetEntry("x11");
102102
if (entry != null)
103103
{
104104
var hashrate = user["hashrate_x11"].ExtractDecimal();
105105
entry.AcceptSpeed = hashrate / 1000;
106106
}
107107

108-
entry = PriceEntries.FirstOrDefault(o => o.AlgoName == "scrypt");
108+
entry = GetEntry("scrypt");
109109
if (entry != null)
110110
{
111111
var hashrate = user["hashrate_scrypt"].ExtractDecimal();

MinerControl/Services/ManualService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public override void Initialize(IDictionary<string, object> data)
2121
foreach (var rawitem in items)
2222
{
2323
var item = rawitem as Dictionary<string, object>;
24-
var entry = GetEntry(item);
24+
var entry = CreateEntry(item);
2525

2626
if (item.ContainsKey("price"))
2727
entry.Price = item["price"].ExtractDecimal();

MinerControl/Services/NiceHashServiceBase.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ public override void Initialize(IDictionary<string, object> data)
2525
foreach (var rawitem in items)
2626
{
2727
var item = rawitem as Dictionary<string, object>;
28-
var entry = GetEntry(item);
29-
entry.AlgorithmId = GetAgorithmId(entry.AlgoName);
28+
var entry = CreateEntry(item);
29+
if (string.IsNullOrWhiteSpace(entry.PriceId))
30+
entry.PriceId = GetAgorithmId(entry.AlgoName).ToString();
3031

3132
Add(entry);
3233
}
@@ -50,8 +51,8 @@ private void ProcessPrices(object jsonData)
5051
foreach (var stat in stats)
5152
{
5253
var item = stat as Dictionary<string, object>;
53-
var algo = item["algo"] as int?;
54-
var entry = PriceEntries.FirstOrDefault(o => o.AlgorithmId == algo);
54+
var algo = item["algo"].ToString();
55+
var entry = GetEntry(algo);
5556
if (entry == null) continue;
5657

5758
entry.Price = item["price"].ExtractDecimal();
@@ -83,8 +84,8 @@ private void ProcessBalances(object jsonData)
8384
{
8485
var item = stat as Dictionary<string, object>;
8586
totalBalance += item["balance"].ExtractDecimal();
86-
var algo = int.Parse(item["algo"].ToString());
87-
var entry = PriceEntries.FirstOrDefault(o => o.AlgorithmId == algo);
87+
var algo = item.GetString("algo");
88+
var entry = GetEntry(algo);
8889
if (entry == null) continue;
8990

9091
entry.Balance = item["balance"].ExtractDecimal();

MinerControl/Services/ServiceBase.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private string ProcessCommon(string raw, AlgorithmEntry algo)
106106
.Replace("_APARAM3_", algo.Param3);
107107
}
108108

109-
protected TEntry GetEntry(Dictionary<string, object> item)
109+
protected TEntry CreateEntry(Dictionary<string, object> item)
110110
{
111111
var entry = new TEntry();
112112
entry.MiningEngine = MiningEngine;
@@ -115,6 +115,7 @@ protected TEntry GetEntry(Dictionary<string, object> item)
115115
entry.AlgoName = item.GetString("algo");
116116
var algo = MiningEngine.AlgorithmEntries.Single(o => o.Name == entry.AlgoName);
117117
entry.Name = algo.Display;
118+
entry.PriceId = item.GetString("priceid");
118119
entry.Hashrate = algo.Hashrate;
119120
entry.Power = algo.Power;
120121
entry.Weight = _weight;
@@ -138,12 +139,17 @@ protected void Add(TEntry entry)
138139
MiningEngine.PriceEntries.Add(entry);
139140
}
140141

141-
protected string GetAlgoName(string name)
142+
private string GetAlgoName(string name)
142143
{
143144
if (AlgoTranslations == null || !AlgoTranslations.ContainsKey(name)) return name;
144145
return AlgoTranslations[name];
145146
}
146147

148+
protected TEntry GetEntry(string algo)
149+
{
150+
return PriceEntries.FirstOrDefault(o => (o.PriceId != null && o.PriceId == algo) || (o.PriceId == null && o.AlgoName == GetAlgoName(algo)));
151+
}
152+
147153
protected void ClearStalePrices()
148154
{
149155
if (!LastUpdated.HasValue || LastUpdated.Value.AddMinutes(30) > DateTime.Now) return;

0 commit comments

Comments
 (0)