Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
ClaymoreDual fix workername, OptiminerZcash wait before API call (fix…
Browse files Browse the repository at this point in the history
… restart loop)
S74nk0 committed Mar 6, 2017
1 parent af1b015 commit ea5cea6
Showing 4 changed files with 72 additions and 59 deletions.
10 changes: 4 additions & 6 deletions NiceHashMiner/Miners/ClaymoreDual.cs
Original file line number Diff line number Diff line change
@@ -26,10 +26,8 @@ protected override int GET_MAX_CooldownTimeInMilliseconds() {
}

private string GetStartCommand(string url, string btcAdress, string worker) {
string useWorker = worker;
if (useWorker == null || useWorker == "") {
useWorker = "worker1";
}
string username = GetUsername(btcAdress, worker);

string dualModeParams = "";
foreach (var pair in MiningSetup.MiningPairs) {
if (pair.CurrentExtraLaunchParameters.Contains("-dual=")) {
@@ -52,14 +50,14 @@ private string GetStartCommand(string url, string btcAdress, string worker) {
}
if (dual != AlgorithmType.NONE) {
string urlSecond = Globals.GetLocationURL(dual, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], this.ConectionType);
dualModeParams = String.Format(" {0} -dpool {1} -dwal {2}", coinP, urlSecond, btcAdress);
dualModeParams = String.Format(" {0} -dpool {1} -dwal {2}", coinP, urlSecond, username);
break;
}
}
}
return " "
+ GetDevicesCommandString()
+ String.Format(" -epool {0} -ewal {1} -mport -{2} -eworker {3} -esm 3 -epsw x -allpools 1", url, btcAdress, APIPort, useWorker)
+ String.Format(" -epool {0} -ewal {1} -mport -{2} -esm 3 -epsw x -allpools 1", url, username, APIPort)
+ dualModeParams;
}

64 changes: 39 additions & 25 deletions NiceHashMiner/Miners/Equihash/OptiminerZcashMiner.cs
Original file line number Diff line number Diff line change
@@ -36,10 +36,19 @@ private class JsonApiResponse {
public Stratum stratum;
}

// give some time or else it will crash
Stopwatch _startAPI = null;
bool _skipAPICheck = true;
int waitSeconds = 30;

public override void Start(string url, string btcAdress, string worker) {
string username = GetUsername(btcAdress, worker);
LastCommandLine = " " + GetDevicesCommandString() + " -m " + APIPort + " -s " + url + " -u " + username + " -p x";
ProcessHandle = _Start();

//
_startAPI = new Stopwatch();
_startAPI.Start();
}

protected override void _Stop(MinerStopType willswitch) {
@@ -67,36 +76,41 @@ public override APIData GetSummary() {
_currentMinerReadStatus = MinerAPIReadStatus.NONE;
APIData ad = new APIData(MiningSetup.CurrentAlgorithmType);

JsonApiResponse resp = null;
try {
string DataToSend = GetHttpRequestNHMAgentStrin("");
string respStr = GetAPIData(APIPort, DataToSend, true);
if (respStr != null && respStr.Contains("{")) {
int start = respStr.IndexOf("{");
if (start > -1) {
string respStrJSON = respStr.Substring(start);
resp = JsonConvert.DeserializeObject<JsonApiResponse>(respStrJSON.Trim(), Globals.JsonSettings);
if (_skipAPICheck == false) {
JsonApiResponse resp = null;
try {
string DataToSend = GetHttpRequestNHMAgentStrin("");
string respStr = GetAPIData(APIPort, DataToSend, true);
if (respStr != null && respStr.Contains("{")) {
int start = respStr.IndexOf("{");
if (start > -1) {
string respStrJSON = respStr.Substring(start);
resp = JsonConvert.DeserializeObject<JsonApiResponse>(respStrJSON.Trim(), Globals.JsonSettings);
}
}
//Helpers.ConsolePrint("OptiminerZcashMiner API back:", respStr);
} catch (Exception ex) {
Helpers.ConsolePrint("OptiminerZcashMiner", "GetSummary exception: " + ex.Message);
}
//Helpers.ConsolePrint("OptiminerZcashMiner API back:", respStr);
} catch (Exception ex) {
Helpers.ConsolePrint("OptiminerZcashMiner", "GetSummary exception: " + ex.Message);
}

if (resp != null && resp.solution_rate != null) {
//Helpers.ConsolePrint("OptiminerZcashMiner API back:", "resp != null && resp.error == null");
const string total_key = "Total";
const string _5s_key = "5s";
if (resp.solution_rate.ContainsKey(total_key)) {
var total_solution_rate_dict = resp.solution_rate[total_key];
if (total_solution_rate_dict != null && total_solution_rate_dict.ContainsKey(_5s_key)) {
ad.Speed = total_solution_rate_dict[_5s_key];
_currentMinerReadStatus = MinerAPIReadStatus.GOT_READ;
if (resp != null && resp.solution_rate != null) {
//Helpers.ConsolePrint("OptiminerZcashMiner API back:", "resp != null && resp.error == null");
const string total_key = "Total";
const string _5s_key = "5s";
if (resp.solution_rate.ContainsKey(total_key)) {
var total_solution_rate_dict = resp.solution_rate[total_key];
if (total_solution_rate_dict != null && total_solution_rate_dict.ContainsKey(_5s_key)) {
ad.Speed = total_solution_rate_dict[_5s_key];
_currentMinerReadStatus = MinerAPIReadStatus.GOT_READ;
}
}
if (ad.Speed == 0) {
_currentMinerReadStatus = MinerAPIReadStatus.READ_SPEED_ZERO;
}
}
if (ad.Speed == 0) {
_currentMinerReadStatus = MinerAPIReadStatus.READ_SPEED_ZERO;
}
} else if (_skipAPICheck && _startAPI.Elapsed.TotalSeconds > waitSeconds) {
_startAPI.Stop();
_skipAPICheck = false;
}

return ad;
50 changes: 25 additions & 25 deletions NiceHashMiner/Miners/Grouping/MinerPaths.cs
Original file line number Diff line number Diff line change
@@ -26,15 +26,15 @@ public static class Data {
public const string ccminer_tpruvot = _bin + @"\ccminer_tpruvot.exe";
public const string ccminer_cryptonight = _bin + @"\ccminer_cryptonight.exe";
public const string ccminer_x11gost = _bin + @"\ccminer_x11gost.exe";
/// <summary>
/// cpuminers opt new
/// </summary>
public const string cpuminer_opt_AVX2_AES = _bin + @"\cpuminer_opt_AVX2_AES.exe";
public const string cpuminer_opt_AVX2 = _bin + @"\cpuminer_opt_AVX2.exe";
public const string cpuminer_opt_AVX_AES = _bin + @"\cpuminer_opt_AVX_AES.exe";
public const string cpuminer_opt_AVX = _bin + @"\cpuminer_opt_AVX.exe";
public const string cpuminer_opt_AES = _bin + @"\cpuminer_opt_AES.exe";
public const string cpuminer_opt_SSE2 = _bin + @"\cpuminer_opt_SSE2.exe";
///// <summary>
///// cpuminers opt new
///// </summary>
//public const string cpuminer_opt_AVX2_AES = _bin + @"\cpuminer_opt_AVX2_AES.exe";
//public const string cpuminer_opt_AVX2 = _bin + @"\cpuminer_opt_AVX2.exe";
//public const string cpuminer_opt_AVX_AES = _bin + @"\cpuminer_opt_AVX_AES.exe";
//public const string cpuminer_opt_AVX = _bin + @"\cpuminer_opt_AVX.exe";
//public const string cpuminer_opt_AES = _bin + @"\cpuminer_opt_AES.exe";
//public const string cpuminer_opt_SSE2 = _bin + @"\cpuminer_opt_SSE2.exe";
/// <summary>
/// ethminers
/// </summary>
@@ -78,8 +78,8 @@ public static bool IsMinerAlgorithmAvaliable(List<Algorithm> algos, MinerBaseTyp

public static string GetPathFor(MinerBaseType minerBaseType, AlgorithmType algoType, DeviceGroupType devGroupType, string devCodenameAMD, bool isOptimizedAMD, CPUExtensionType MostOptimizedCPUExtensionType) {
switch (minerBaseType) {
case MinerBaseType.cpuminer:
return CPU_GROUP.cpu_miner_opt(MostOptimizedCPUExtensionType);
//case MinerBaseType.cpuminer:
// return CPU_GROUP.cpu_miner_opt(MostOptimizedCPUExtensionType);
case MinerBaseType.ccminer:
return NVIDIA_GROUPS.ccminer_path(algoType, devGroupType);
case MinerBaseType.sgminer:
@@ -225,20 +225,20 @@ public static string ClaymorePath(AlgorithmType type) {
}
}

static class CPU_GROUP {
public static string cpu_miner_opt(CPUExtensionType type) {
// algorithmType is not needed ATM
// algorithmType: AlgorithmType
if (CPUExtensionType.AVX2_AES == type) { return Data.cpuminer_opt_AVX2_AES; }
if (CPUExtensionType.AVX2 == type) { return Data.cpuminer_opt_AVX2; }
if (CPUExtensionType.AVX_AES == type) { return Data.cpuminer_opt_AVX_AES; }
if (CPUExtensionType.AVX == type) { return Data.cpuminer_opt_AVX; }
if (CPUExtensionType.AES == type) { return Data.cpuminer_opt_AES; }
if (CPUExtensionType.SSE2 == type) { return Data.cpuminer_opt_SSE2; }

return Data.NONE; // should not happen
}
}
//static class CPU_GROUP {
// public static string cpu_miner_opt(CPUExtensionType type) {
// // algorithmType is not needed ATM
// // algorithmType: AlgorithmType
// if (CPUExtensionType.AVX2_AES == type) { return Data.cpuminer_opt_AVX2_AES; }
// if (CPUExtensionType.AVX2 == type) { return Data.cpuminer_opt_AVX2; }
// if (CPUExtensionType.AVX_AES == type) { return Data.cpuminer_opt_AVX_AES; }
// if (CPUExtensionType.AVX == type) { return Data.cpuminer_opt_AVX; }
// if (CPUExtensionType.AES == type) { return Data.cpuminer_opt_AES; }
// if (CPUExtensionType.SSE2 == type) { return Data.cpuminer_opt_SSE2; }

// return Data.NONE; // should not happen
// }
//}

}
}
7 changes: 4 additions & 3 deletions NiceHashMiner/Miners/Parsing/ExtraLaunchParameters.cs
Original file line number Diff line number Diff line change
@@ -176,10 +176,11 @@ public static class ExtraLaunchParameters {
new MinerOptionPackage(
MinerType.OptiminerZcash,
new List<MinerOption>() {
new MinerOption("ForceGenericKernel" , "", "--force-generic-kernel", null, MinerOptionFlagType.Uni, ""),
new MinerOption("ExperimentalKernel" , "", "--experimental-kernel", null, MinerOptionFlagType.Uni, ""),
new MinerOption("nodevfee" , "", "--nodevfee", null, MinerOptionFlagType.Uni, ""),
new MinerOption("ForceGenericKernel" , "--force-generic-kernel", "--force-generic-kernel", null, MinerOptionFlagType.Uni, ""),
new MinerOption("ExperimentalKernel" , "--experimental-kernel", "--experimental-kernel", null, MinerOptionFlagType.Uni, ""),
new MinerOption("nodevfee" , "--nodevfee", "--nodevfee", null, MinerOptionFlagType.Uni, ""),
new MinerOption("Intensity" , "-i", "--intensity", "0", MinerOptionFlagType.DuplicateMultiParam, ""),
new MinerOption("PciMode" , "--pci-mode", "--pci-mode", "", MinerOptionFlagType.SingleParam, ""),
},
new List<MinerOption>()
),

0 comments on commit ea5cea6

Please sign in to comment.