Permalink
Browse files

Removed Westhash + moved price&fee from manual out of algos + init co…

…in mining
  • Loading branch information...
1 parent 6b65182 commit 9bbd836bbd182a64f91e1b91ce013488297a25c9 @KBomba committed Feb 17, 2016
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <metadata name="historyChart.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>False</value>
+ </metadata>
<metadata name="tmrPriceCheck.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
@@ -6365,9 +6368,6 @@
<metadata name="tmrExchangeUpdate.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>391, 20</value>
</metadata>
- <metadata name="historyChart.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>False</value>
- </metadata>
<metadata name="cmsDataGrid.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>553, 20</value>
</metadata>
Oops, something went wrong.
@@ -70,9 +70,11 @@
<Compile Include="History\TotalHistoryForm.Designer.cs">
<DependentUpon>TotalHistoryForm.cs</DependentUpon>
</Compile>
+ <Compile Include="PriceEntries\CoinPriceEntry.cs" />
<Compile Include="PriceEntries\YaampClonePriceEntry.cs" />
<Compile Include="PriceEntries\LtcRabbitPriceEntry.cs" />
<Compile Include="PriceEntries\WePayBtcPriceEntry.cs" />
+ <Compile Include="Services\CoinService.cs" />
<Compile Include="Services\YaampCloneService.cs" />
<Compile Include="Services\LtcRabbitService.cs" />
<Compile Include="Services\WePayBtcService.cs" />
@@ -390,22 +390,33 @@ public bool LoadConfig()
case "ltcrabbit": break;
case "wepaybtc": break;
default :
+ Dictionary<string, object> serviceData = data[service] as Dictionary<string, object>;
if (service.StartsWith("manual", StringComparison.InvariantCultureIgnoreCase))
{
- Dictionary<string, object> serviceData = data[service] as Dictionary<string, object>;
if (serviceData != null && serviceData.ContainsKey("name"))
{
- LoadService(new ManualService(serviceData.GetString("name")), data, service);
+ LoadService(new ManualService(serviceData.GetString("name")), serviceData);
}
else
{
- LoadService(new ManualService(service), data, service);
+ LoadService(new ManualService(service), serviceData);
+ }
+ }
+ else if (service.EndsWith("coin", StringComparison.InvariantCultureIgnoreCase))
+ {
+ if (serviceData != null && serviceData.ContainsKey("name"))
+ {
+ LoadService(new CoinService(serviceData.GetString("name")), serviceData);
+ }
+ else
+ {
+ LoadService(new CoinService(service), serviceData);
}
}
else
{
//All others are treated as YaampClones
- LoadService(new YaampCloneService(service), data, service);
+ LoadService(new YaampCloneService(service), serviceData);
}
break;
}
@@ -455,6 +466,11 @@ private void LoadService(IService service, IDictionary<string, object> data, str
Dictionary<string, object> serviceData = data[name] as Dictionary<string, object>;
+ LoadService(service, serviceData);
+ }
+
+ private void LoadService(IService service, Dictionary<string, object> serviceData)
+ {
service.MiningEngine = this;
_services.Add(service);
service.Initialize(serviceData);
@@ -0,0 +1,13 @@
+namespace MinerControl.PriceEntries
+{
+ public class CoinPriceEntry : PriceEntryBase
+ {
+ public decimal FeePercent { get; set; }
+
+ public override decimal Fees
+ {
+ get { return Earn*(FeePercent/100); }
+ set { base.Fees = value; }
+ }
+ }
+}
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using MinerControl.PriceEntries;
+using MinerControl.Utility;
+
+namespace MinerControl.Services
+{
+ public class CoinService: ServiceBase<CoinPriceEntry>
+ {
+ private const string Url = "http://www.whattomine.com/coins.json";
+ private decimal _minVolume;
+
+ public CoinService(string pool)
+ {
+ ServiceName = pool;
+ DonationAccount = "VrovuTn6CTvRQfXCY6Z4uifYiDturyMuhv";
+ }
+
+ public override void Initialize(IDictionary<string, object> data)
+ {
+ ExtractCommon(data);
+
+ decimal fee = 0;
+ if (data.ContainsKey("fee"))
+ fee = data["fee"].ExtractDecimal();
+ if (data.ContainsKey("minvolume"))
+ _minVolume = data["minvolume"].ExtractDecimal();
+
+ object[] items = data["algos"] as object[];
+ foreach (object rawitem in items)
+ {
+ Dictionary<string, object> item = rawitem as Dictionary<string, object>;
+ CoinPriceEntry entry = CreateEntry(item);
+
+ entry.FeePercent = fee;
+
+ Add(entry);
+ }
+ }
+
+ public override void CheckPrices()
+ {
+ ClearStalePrices();
+
+ WebUtil.DownloadJson(Url, ProcessPrices);
+ }
+
+ private void ProcessPrices(object jsonData)
+ {
+ Dictionary<string, object> data = jsonData as Dictionary<string, object>;
+
+ lock (MiningEngine)
+ {
+ foreach (string key in data.Keys)
+ {
+ object rawitem = data[key];
+ Dictionary<string, object> item = rawitem as Dictionary<string, object>;
+ string algo = key.ToLower();
+
+ CoinPriceEntry entry = GetEntry(algo);
+ if (entry == null) continue;
+
+ decimal price;
+ switch (0)
+ {
+ case 1:
+ price = item["estimate_last24h"].ExtractDecimal();
+ break;
+ case 2:
+ price = item["actual_last24h"].ExtractDecimal();
+ break;
+ default:
+ price = item["estimate_current"].ExtractDecimal();
+ break;
+ }
+ entry.Price = algo != "sha256" ? price*1000 : price;
+ }
+
+ MiningEngine.PricesUpdated = true;
+ MiningEngine.HasPrices = true;
+
+ LastUpdated = DateTime.Now;
+
+ UpdateHistory();
+ }
+ }
+ }
+}
@@ -20,17 +20,19 @@ public override void Initialize(IDictionary<string, object> data)
{
ExtractCommon(data);
+ decimal price = 0, fee = 0;
+ if (data.ContainsKey("price"))
+ price = data["price"].ExtractDecimal();
+ if (data.ContainsKey("fee"))
+ fee = data["fee"].ExtractDecimal();
+
object[] items = data["algos"] as object[];
foreach (object rawitem in items)
{
Dictionary<string, object> item = rawitem as Dictionary<string, object>;
ManualPriceEntry entry = CreateEntry(item);
-
- if (item.ContainsKey("price"))
- entry.Price = item["price"].ExtractDecimal();
- if (item.ContainsKey("fee"))
- entry.FeePercent = item["fee"].ExtractDecimal();
-
+ entry.Price = price;
+ entry.FeePercent = fee;
Add(entry);
}
}
@@ -29,7 +29,6 @@ public class NiceHashService : ServiceBase<NiceHashPriceEntry>
};
private Dictionary<string, double> _pingTimes;
- private bool _useWestHash; // When .usa, .hk, or .jp is used, balance calls should be done to westhash
public bool DetectStratum;
public NiceHashService()
@@ -52,7 +51,6 @@ public override void Initialize(IDictionary<string, object> data)
else
{
DetectStratum = false;
- if (!_param1.Contains(".eu.") && !_param2.Contains(".eu.") && !_param3.Contains(".eu.")) _useWestHash = true;
}
object[] items = data["algos"] as object[];
@@ -72,9 +70,7 @@ public override void CheckPrices()
ClearStalePrices();
WebUtil.DownloadJson("https://www.nicehash.com/api?method=stats.global.current", ProcessPrices);
- string apiUrl = _useWestHash
- ? "https://www.westhash.com/api?method=stats.provider&addr={0}"
- : "https://www.nicehash.com/api?method=stats.provider&addr={0}";
+ string apiUrl = "https://www.nicehash.com/api?method=stats.provider&addr={0}";
WebUtil.DownloadJson(
string.Format(apiUrl, _account), ProcessBalances);
}
@@ -190,7 +186,6 @@ private void InitPingTimes()
}
_pingTimes = clone;
- DetermineWestHashUsage();
}
public async void CheckPingTimes()
@@ -219,7 +214,6 @@ private void InitPingTimes()
}
_pingTimes = clone;
- DetermineWestHashUsage();
}
private static double CheckRoundTripTime(PingReply reply, string url, double roundTripTime)
@@ -247,12 +241,6 @@ private static double CheckRoundTripTime(PingReply reply, string url, double rou
return roundTripTime;
}
- private void DetermineWestHashUsage()
- {
- _useWestHash = _pingTimes.OrderBy(ping => ping.Value).First().Key != ".eu.nicehash.com";
- ServiceName = _useWestHash ? "WestHash" : "NiceHash";
- }
-
public string GetBestStratum(string algorithmName)
{
string substituteAlgo;

0 comments on commit 9bbd836

Please sign in to comment.