Permalink
Browse files

Configuration for algo api id to avoid hard coding.

  • Loading branch information...
1 parent 8703c9d commit 005a8f79ae9d96a93b5b09d1fc2b8e4da07bc7ab @StuffOfInterest StuffOfInterest committed Dec 15, 2014
@@ -177,7 +177,7 @@ private void InitializeComponent()
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(102, 13);
this.label13.TabIndex = 10;
- this.label13.Text = "Miner Control v1.5.6";
+ this.label13.Text = "Miner Control v1.6.0";
//
// notifyIcon
//
@@ -29,6 +29,7 @@
{ "name": "scryptn", display: "Scrypt-N", "hashrate": 253, "power": 60, "aparam1": "c:\\windows\\system32", "aparam2": "cmd.exe", "aparam3": "/c test-run.bat -a scryptn -batch" },
{ "name": "keccak", display: "Keccak", "hashrate": 34000, "power": 50, "aparam1": "", "aparam2": "TestMiner.exe", "aparam3": "-a keccak" },
{ "name": "qubit", display: "Qubit", "hashrate": 7500, "power": 50, "aparam1": "", "aparam2": "TestMiner.exe", "aparam3": "-a qubit" },
+ { "name": "lyra2", display: "Lyra2RE", "hashrate": 1216, "power": 50, "aparam1": "", "aparam2": "TestMiner.exe", "aparam3": "-a lyra2re" },
{ "name": "sha256", display: "SHA256", "hashrate": 10000, "power": 50, "aparam1": "c:\\windows\\system32", "aparam2": "cmd.exe", "aparam3": "/c test-run.bat -a sha256 -batch" }
],
"nicehash": {
@@ -46,6 +47,7 @@
{ "algo": "keccak", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3338 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
{ "algo": "nist5", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3340 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
{ "algo": "neoscrypt", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3341 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
+ { "algo": "lyra2", "priceid": "9", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3342 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
{ "algo": "sha256", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3332 -u _ACCOUNT_._WORKER_ _SPARAM2_", "usewindow": true }
]
},
@@ -62,6 +64,7 @@
{ "algo": "scryptn", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3335 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
{ "algo": "keccak", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3338 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
{ "algo": "nist5", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3340 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
+ { "algo": "lyra2", "priceid": "9", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3342 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
{ "algo": "neoscrypt", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3341 -u _ACCOUNT_._WORKER_ _SPARAM2_" }
]
},
@@ -92,6 +95,7 @@
{ "algo": "x15", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3733 _ACCOUNT_ _SPARAM2_" },
{ "algo": "quark", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:4033 _ACCOUNT_ _SPARAM2_" },
{ "algo": "nist5", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3833 _ACCOUNT_ _SPARAM2_" },
+ { "algo": "lyra2", "priceid": "lyra2", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:4433 -u _ACCOUNT_._WORKER_ _SPARAM2_" },
{ "algo": "scrypt", "folder": "_APARAM1_", "command": "_APARAM2_", "arguments": "_APARAM3_ _SPARAM1_:3433 _ACCOUNT_ _SPARAM2_" }
]
},
@@ -7,8 +7,6 @@ namespace MinerControl.PriceEntries
{
public class NiceHashPriceEntry : PriceEntryBase
{
- public int AlgorithmId { get; set; }
-
public override decimal Fees
{
get { return Earn * 0.02m; }
@@ -16,6 +16,7 @@ public PriceEntryBase()
public MiningEngine MiningEngine { get; set; }
public int Id { get; set; }
public IService ServiceEntry { get; set; }
+ public string PriceId { get; set; }
public string AlgoName { get; set; }
public string Name { get; set; }
public bool UseWindow { get; set; }
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.6.0")]
-[assembly: AssemblyFileVersion("1.5.6.0")]
+[assembly: AssemblyVersion("1.6.0.0")]
+[assembly: AssemblyFileVersion("1.6.0.0")]
@@ -40,7 +40,7 @@ public override void Initialize(IDictionary<string, object> data)
foreach (var rawitem in items)
{
var item = rawitem as Dictionary<string, object>;
- var entry = GetEntry(item);
+ var entry = CreateEntry(item);
entry.Donation = _donation;
Add(entry);
@@ -64,7 +64,7 @@ private void ProcessPrices(object jsonData)
var algo = key.ToLower();
var price = data[key].ExtractDecimal();
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == GetAlgoName(algo));
+ var entry = GetEntry(algo);
if (entry == null) continue;
entry.Price = price * 1000;
@@ -87,7 +87,7 @@ private void ProcessBalances(object jsonData)
var algo = key.ToLower();
var balance = data[key].ExtractDecimal();
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == GetAlgoName(algo));
+ var entry = GetEntry(algo);
if (entry == null) continue;
entry.Balance = balance;
@@ -49,7 +49,7 @@ public override void Initialize(IDictionary<string, object> data)
foreach (var rawitem in items)
{
var item = rawitem as Dictionary<string, object>;
- var entry = GetEntry(item);
+ var entry = CreateEntry(item);
Add(entry);
}
@@ -76,7 +76,7 @@ private void ProcessPrices(object jsonData)
var item = rawitem as Dictionary<string, object>;
var algo = key.ToLower();
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == algo);
+ var entry = GetEntry(algo);
if (entry == null) continue;
entry.Price = item["btc_mh"].ExtractDecimal() * 1000;
@@ -98,14 +98,14 @@ private void ProcessBalances(object jsonData)
var user = getappdata["user"] as Dictionary<string, object>;
Balance = user["balance_btc"].ExtractDecimal();
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == "x11");
+ var entry = GetEntry("x11");
if (entry != null)
{
var hashrate = user["hashrate_x11"].ExtractDecimal();
entry.AcceptSpeed = hashrate / 1000;
}
- entry = PriceEntries.FirstOrDefault(o => o.AlgoName == "scrypt");
+ entry = GetEntry("scrypt");
if (entry != null)
{
var hashrate = user["hashrate_scrypt"].ExtractDecimal();
@@ -21,7 +21,7 @@ public override void Initialize(IDictionary<string, object> data)
foreach (var rawitem in items)
{
var item = rawitem as Dictionary<string, object>;
- var entry = GetEntry(item);
+ var entry = CreateEntry(item);
if (item.ContainsKey("price"))
entry.Price = item["price"].ExtractDecimal();
@@ -25,8 +25,9 @@ public override void Initialize(IDictionary<string, object> data)
foreach (var rawitem in items)
{
var item = rawitem as Dictionary<string, object>;
- var entry = GetEntry(item);
- entry.AlgorithmId = GetAgorithmId(entry.AlgoName);
+ var entry = CreateEntry(item);
+ if (string.IsNullOrWhiteSpace(entry.PriceId))
+ entry.PriceId = GetAgorithmId(entry.AlgoName).ToString();
Add(entry);
}
@@ -50,8 +51,8 @@ private void ProcessPrices(object jsonData)
foreach (var stat in stats)
{
var item = stat as Dictionary<string, object>;
- var algo = item["algo"] as int?;
- var entry = PriceEntries.FirstOrDefault(o => o.AlgorithmId == algo);
+ var algo = item["algo"].ToString();
+ var entry = GetEntry(algo);
if (entry == null) continue;
entry.Price = item["price"].ExtractDecimal();
@@ -83,8 +84,8 @@ private void ProcessBalances(object jsonData)
{
var item = stat as Dictionary<string, object>;
totalBalance += item["balance"].ExtractDecimal();
- var algo = int.Parse(item["algo"].ToString());
- var entry = PriceEntries.FirstOrDefault(o => o.AlgorithmId == algo);
+ var algo = item.GetString("algo");
+ var entry = GetEntry(algo);
if (entry == null) continue;
entry.Balance = item["balance"].ExtractDecimal();
@@ -106,7 +106,7 @@ private string ProcessCommon(string raw, AlgorithmEntry algo)
.Replace("_APARAM3_", algo.Param3);
}
- protected TEntry GetEntry(Dictionary<string, object> item)
+ protected TEntry CreateEntry(Dictionary<string, object> item)
{
var entry = new TEntry();
entry.MiningEngine = MiningEngine;
@@ -115,6 +115,7 @@ protected TEntry GetEntry(Dictionary<string, object> item)
entry.AlgoName = item.GetString("algo");
var algo = MiningEngine.AlgorithmEntries.Single(o => o.Name == entry.AlgoName);
entry.Name = algo.Display;
+ entry.PriceId = item.GetString("priceid");
entry.Hashrate = algo.Hashrate;
entry.Power = algo.Power;
entry.Weight = _weight;
@@ -138,12 +139,17 @@ protected void Add(TEntry entry)
MiningEngine.PriceEntries.Add(entry);
}
- protected string GetAlgoName(string name)
+ private string GetAlgoName(string name)
{
if (AlgoTranslations == null || !AlgoTranslations.ContainsKey(name)) return name;
return AlgoTranslations[name];
}
+ protected TEntry GetEntry(string algo)
+ {
+ return PriceEntries.FirstOrDefault(o => (o.PriceId != null && o.PriceId == algo) || (o.PriceId == null && o.AlgoName == GetAlgoName(algo)));
+ }
+
protected void ClearStalePrices()
{
if (!LastUpdated.HasValue || LastUpdated.Value.AddMinutes(30) > DateTime.Now) return;
@@ -37,7 +37,7 @@ public override void Initialize(IDictionary<string, object> data)
foreach (var rawitem in items)
{
var item = rawitem as Dictionary<string, object>;
- var entry = GetEntry(item);
+ var entry = CreateEntry(item);
Add(entry);
}
}
@@ -58,7 +58,7 @@ private void ProcessPrices(object jsonData)
{
var item = rawitem as Dictionary<string, object>;
var algo = item.GetString("algo");
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == GetAlgoName(algo));
+ var entry = GetEntry(algo);
if (entry == null) continue;
entry.Price = item["actual"].ExtractDecimal() * 1000;
@@ -58,7 +58,7 @@ public override void Initialize(IDictionary<string, object> data)
foreach (var rawitem in items)
{
var item = rawitem as Dictionary<string, object>;
- var entry = GetEntry(item);
+ var entry = CreateEntry(item);
Add(entry);
}
@@ -80,9 +80,8 @@ private void ProcessPrices(object jsonData)
{
var rawitem = data[key];
var item = rawitem as Dictionary<string, object>;
- var algo = GetAlgoName(key.ToLower());
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == algo);
+ var entry = GetEntry(key.ToLower());
if (entry == null) continue;
var earnings = item["earnings"] as object[];
@@ -115,9 +114,8 @@ private void ProcessBalances(object jsonData)
{
var rawitem = data[key];
var item = rawitem as Dictionary<string, object>;
- var algo = GetAlgoName(key.ToLower());
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == algo);
+ var entry = GetEntry(key.ToLower());
if (entry == null) continue;
entry.AcceptSpeed = item["hashrate"].ExtractDecimal() / 1000000;
@@ -33,7 +33,7 @@ public override void Initialize(IDictionary<string, object> data)
foreach (var rawitem in items)
{
var item = rawitem as Dictionary<string, object>;
- var entry = GetEntry(item);
+ var entry = CreateEntry(item);
Add(entry);
}
@@ -57,7 +57,7 @@ private void ProcessPrices(object jsonData)
var item = rawitem as Dictionary<string, object>;
var algo = key.ToLower();
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == algo);
+ var entry = GetEntry(algo);
if (entry == null) continue;
entry.Price = data[key].ExtractDecimal() * 1000;
@@ -22,7 +22,7 @@ public override void Initialize(IDictionary<string, object> data)
foreach (var rawitem in items)
{
var item = rawitem as Dictionary<string, object>;
- var entry = GetEntry(item);
+ var entry = CreateEntry(item);
Add(entry);
}
@@ -47,7 +47,7 @@ private void ProcessPrices(object jsonData)
var item = rawitem as Dictionary<string, object>;
var algo = key.ToLower();
- var entry = PriceEntries.FirstOrDefault(o => o.AlgoName == algo);
+ var entry = GetEntry(algo);
if (entry == null) continue;
entry.Price = item["estimate_current"].ExtractDecimal() * 1000;

0 comments on commit 005a8f7

Please sign in to comment.