Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 44 additions & 7 deletions NiceHashMiner/Algorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ public class Algorithm {
public readonly string AlgorithmName;
public readonly string MinerBaseTypeName;
public readonly AlgorithmType NiceHashID;
public readonly AlgorithmType SecondaryNiceHashID;
public readonly MinerBaseType MinerBaseType;
public readonly string AlgorithmStringID;
// Miner name is used for miner ALGO flag parameter
public readonly string MinerName;
public double BenchmarkSpeed { get; set; }
public double SecondaryBenchmarkSpeed { get; set; }
public string ExtraLaunchParameters { get; set; }
public bool Enabled { get; set; }

Expand All @@ -23,25 +25,30 @@ public class Algorithm {

// avarage speed of same devices to increase mining stability
public double AvaragedSpeed { get; set; }
public double SecondaryAveragedSpeed { get; set; }
// based on device and settings here we set the miner path
public string MinerBinaryPath = "";
// these are changing (logging reasons)
public double CurrentProfit = 0;
public double CurNhmSMADataVal = 0;
public double SecondaryCurNhmSMADataVal = 0;

public Algorithm(MinerBaseType minerBaseType, AlgorithmType niceHashID, string minerName, AlgorithmType secondaryNiceHashID=AlgorithmType.NONE) {
NiceHashID = niceHashID;
SecondaryNiceHashID = secondaryNiceHashID;

public Algorithm(MinerBaseType minerBaseType, AlgorithmType niceHashID, string minerName) {
this.AlgorithmName = AlgorithmNiceHashNames.GetName(niceHashID);
this.AlgorithmName = AlgorithmNiceHashNames.GetName(DualNiceHashID());
this.MinerBaseTypeName = Enum.GetName(typeof(MinerBaseType), minerBaseType);
this.AlgorithmStringID = this.MinerBaseTypeName + "_" + this.AlgorithmName;

MinerBaseType = minerBaseType;
NiceHashID = niceHashID;
MinerName = minerName;

BenchmarkSpeed = 0.0d;
SecondaryBenchmarkSpeed = 0.0d;
ExtraLaunchParameters = "";
LessThreads = 0;
Enabled = true;
Enabled = !IsDual();
BenchmarkStatus = "";
}

Expand All @@ -54,14 +61,24 @@ public string CurPayingRatio {
if (Globals.NiceHashData != null) {
ratio = Globals.NiceHashData[NiceHashID].paying.ToString("F8");
}
if (SecondaryNiceHashID != AlgorithmType.NONE) {
ratio += "/" + Globals.NiceHashData[SecondaryNiceHashID].paying.ToString("F8");
}
return ratio;
}
}
public string CurPayingRate {
get {
string rate = International.GetText("BenchmarkRatioRateN_A");
if (BenchmarkSpeed > 0 && Globals.NiceHashData != null) {
rate = (BenchmarkSpeed * Globals.NiceHashData[NiceHashID].paying * 0.000000001).ToString("F8");
var payingRate = 0.0d;
if (Globals.NiceHashData != null) {
if (BenchmarkSpeed > 0) {
payingRate += BenchmarkSpeed * Globals.NiceHashData[NiceHashID].paying * 0.000000001;
}
if (SecondaryBenchmarkSpeed > 0 && IsDual()) {
payingRate += SecondaryBenchmarkSpeed * Globals.NiceHashData[SecondaryNiceHashID].paying * 0.000000001;
}
rate = payingRate.ToString("F8");
}
return rate;
}
Expand Down Expand Up @@ -98,11 +115,31 @@ public string BenchmarkSpeedString() {
if (Enabled && IsBenchmarkPending && !string.IsNullOrEmpty(BenchmarkStatus)) {
return BenchmarkStatus;
} else if (BenchmarkSpeed > 0) {
return Helpers.FormatSpeedOutput(BenchmarkSpeed);
return Helpers.FormatDualSpeedOutput(BenchmarkSpeed, SecondaryBenchmarkSpeed);
} else if (!IsPendingString() && !string.IsNullOrEmpty(BenchmarkStatus)) {
return BenchmarkStatus;
}
return International.GetText("BenchmarkSpeedStringNone");
}

// return hybrid type if dual, else standard ID
public AlgorithmType DualNiceHashID() {
if (NiceHashID == AlgorithmType.DaggerHashimoto) {
switch (SecondaryNiceHashID) {
case AlgorithmType.Decred:
return AlgorithmType.DaggerDecred;
case AlgorithmType.Lbry:
return AlgorithmType.DaggerLbry;
case AlgorithmType.Pascal:
return AlgorithmType.DaggerPascal;
}
}
return NiceHashID;
}
public bool IsDual() {
return (DualNiceHashID() == AlgorithmType.DaggerDecred ||
DualNiceHashID() == AlgorithmType.DaggerLbry ||
DualNiceHashID() == AlgorithmType.DaggerPascal);
}
}
}
2 changes: 2 additions & 0 deletions NiceHashMiner/Configs/Data/AlgorithmConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ namespace NiceHashMiner.Configs.Data {
public class AlgorithmConfig {
public string Name = ""; // Used as an indicator for easier user interaction
public AlgorithmType NiceHashID = AlgorithmType.NONE;
public AlgorithmType SecondaryNiceHashID = AlgorithmType.NONE;
public MinerBaseType MinerBaseType = MinerBaseType.NONE;
public string MinerName = ""; // probably not needed
public double BenchmarkSpeed = 0;
public double SecondaryBenchmarkSpeed = 0;
public string ExtraLaunchParameters= "";
public bool Enabled = true;
public int LessThreads = 0;
Expand Down
12 changes: 8 additions & 4 deletions NiceHashMiner/Devices/ComputeDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public string GetFullName() {
return String.Format(International.GetText("ComputeDevice_Full_Device_Name"), NameCount, Name);
}

public Algorithm GetAlgorithm(MinerBaseType MinerBaseType, AlgorithmType AlgorithmType) {
int toSetIndex = this.AlgorithmSettings.FindIndex((a) => a.NiceHashID == AlgorithmType && a.MinerBaseType == MinerBaseType);
public Algorithm GetAlgorithm(MinerBaseType MinerBaseType, AlgorithmType AlgorithmType, AlgorithmType SecondaryAlgorithmType) {
int toSetIndex = this.AlgorithmSettings.FindIndex((a) => a.NiceHashID == AlgorithmType && a.MinerBaseType == MinerBaseType && a.SecondaryNiceHashID == SecondaryAlgorithmType);
if (toSetIndex > -1) {
return this.AlgorithmSettings[toSetIndex];
}
Expand All @@ -145,9 +145,10 @@ public Algorithm GetAlgorithm(MinerBaseType MinerBaseType, AlgorithmType Algorit

public void CopyBenchmarkSettingsFrom(ComputeDevice copyBenchCDev) {
foreach (var copyFromAlgo in copyBenchCDev.AlgorithmSettings) {
var setAlgo = GetAlgorithm(copyFromAlgo.MinerBaseType, copyFromAlgo.NiceHashID);
var setAlgo = GetAlgorithm(copyFromAlgo.MinerBaseType, copyFromAlgo.NiceHashID, copyFromAlgo.SecondaryNiceHashID);
if (setAlgo != null) {
setAlgo.BenchmarkSpeed = copyFromAlgo.BenchmarkSpeed;
setAlgo.SecondaryBenchmarkSpeed = copyFromAlgo.SecondaryBenchmarkSpeed;
setAlgo.ExtraLaunchParameters = copyFromAlgo.ExtraLaunchParameters;
setAlgo.LessThreads = copyFromAlgo.LessThreads;
}
Expand All @@ -166,9 +167,10 @@ public void SetAlgorithmDeviceConfig(DeviceBenchmarkConfig config) {
if (config != null && config.DeviceUUID == UUID && config.AlgorithmSettings != null) {
this.AlgorithmSettings = GroupAlgorithms.CreateForDeviceList(this);
foreach (var conf in config.AlgorithmSettings) {
var setAlgo = GetAlgorithm(conf.MinerBaseType, conf.NiceHashID);
var setAlgo = GetAlgorithm(conf.MinerBaseType, conf.NiceHashID, conf.SecondaryNiceHashID);
if (setAlgo != null) {
setAlgo.BenchmarkSpeed = conf.BenchmarkSpeed;
setAlgo.SecondaryBenchmarkSpeed = conf.SecondaryBenchmarkSpeed;
setAlgo.ExtraLaunchParameters = conf.ExtraLaunchParameters;
setAlgo.Enabled = conf.Enabled;
setAlgo.LessThreads = conf.LessThreads;
Expand All @@ -194,9 +196,11 @@ public DeviceBenchmarkConfig GetAlgorithmDeviceConfig() {
AlgorithmConfig conf = new AlgorithmConfig();
conf.Name = algo.AlgorithmStringID;
conf.NiceHashID = algo.NiceHashID;
conf.SecondaryNiceHashID = algo.SecondaryNiceHashID;
conf.MinerBaseType = algo.MinerBaseType;
conf.MinerName = algo.MinerName; // TODO probably not needed
conf.BenchmarkSpeed = algo.BenchmarkSpeed;
conf.SecondaryBenchmarkSpeed = algo.SecondaryBenchmarkSpeed;
conf.ExtraLaunchParameters = algo.ExtraLaunchParameters;
conf.Enabled = algo.Enabled;
conf.LessThreads = algo.LessThreads;
Expand Down
5 changes: 4 additions & 1 deletion NiceHashMiner/Devices/GroupAlgorithms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ public static Dictionary<MinerBaseType, List<Algorithm>> CreateDefaultsForGroup(
new List<Algorithm>() {
new Algorithm(MinerBaseType.ClaymoreAMD, AlgorithmType.CryptoNight, "cryptonight"),
new Algorithm(MinerBaseType.ClaymoreAMD, AlgorithmType.Equihash, "equihash"),
new Algorithm(MinerBaseType.ClaymoreAMD, AlgorithmType.DaggerHashimoto, "")
new Algorithm(MinerBaseType.ClaymoreAMD, AlgorithmType.DaggerHashimoto, ""),
new Algorithm(MinerBaseType.ClaymoreAMD, AlgorithmType.DaggerHashimoto, "", AlgorithmType.Decred),
new Algorithm(MinerBaseType.ClaymoreAMD, AlgorithmType.DaggerHashimoto, "", AlgorithmType.Lbry),
new Algorithm(MinerBaseType.ClaymoreAMD, AlgorithmType.DaggerHashimoto, "", AlgorithmType.Pascal)
}
},
{ MinerBaseType.OptiminerAMD,
Expand Down
4 changes: 4 additions & 0 deletions NiceHashMiner/Enums/AlgorithmType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ namespace NiceHashMiner.Enums
/// </summary>
public enum AlgorithmType : int
{
// dual algos for grouping
DaggerDecred = -5,
DaggerLbry = -4,
DaggerPascal = -3,
INVALID = -2,
NONE = -1,
#region NiceHashAPI
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 28 additions & 4 deletions NiceHashMiner/Forms/Components/AlgorithmSettingsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ public partial class AlgorithmSettingsControl : UserControl, AlgorithmsListView.
public AlgorithmSettingsControl() {
InitializeComponent();
fieldBoxBenchmarkSpeed.SetInputModeDoubleOnly();
secondaryFieldBoxBenchmarkSpeed.SetInputModeDoubleOnly();
field_LessThreads.SetInputModeIntOnly();

field_LessThreads.SetOnTextLeave(LessThreads_Leave);
fieldBoxBenchmarkSpeed.SetOnTextChanged(textChangedBenchmarkSpeed);
secondaryFieldBoxBenchmarkSpeed.SetOnTextChanged(secondaryTextChangedBenchmarkSpeed);
richTextBoxExtraLaunchParameters.TextChanged += textChangedExtraLaunchParameters;

}
Expand All @@ -35,6 +37,7 @@ public void Deselect() {
International.GetText("AlgorithmsListView_GroupBox_NONE"));
Enabled = false;
fieldBoxBenchmarkSpeed.EntryText = "";
secondaryFieldBoxBenchmarkSpeed.EntryText = "";
field_LessThreads.EntryText = "";
richTextBoxExtraLaunchParameters.Text = "";
}
Expand All @@ -46,6 +49,9 @@ public void InitLocale(ToolTip toolTip1) {
fieldBoxBenchmarkSpeed.InitLocale(toolTip1,
International.GetText("Form_Settings_Algo_BenchmarkSpeed") + ":",
International.GetText("Form_Settings_ToolTip_AlgoBenchmarkSpeed"));
secondaryFieldBoxBenchmarkSpeed.InitLocale(toolTip1,
International.GetText("Form_Settings_Algo_SecondaryBenchmarkSpeed") + ":",
International.GetText("Form_Settings_ToolTip_AlgoSecondaryBenchmarkSpeed"));
groupBoxExtraLaunchParameters.Text = International.GetText("Form_Settings_General_ExtraLaunchParameters");
toolTip1.SetToolTip(groupBoxExtraLaunchParameters, International.GetText("Form_Settings_ToolTip_AlgoExtraLaunchParameters"));
toolTip1.SetToolTip(pictureBox1, International.GetText("Form_Settings_ToolTip_AlgoExtraLaunchParameters"));
Expand Down Expand Up @@ -80,6 +86,8 @@ public void SetCurrentlySelected(ListViewItem lvi, ComputeDevice computeDevice)
}
fieldBoxBenchmarkSpeed.EntryText = ParseDoubleDefault(algorithm.BenchmarkSpeed);
richTextBoxExtraLaunchParameters.Text = ParseStringDefault(algorithm.ExtraLaunchParameters);
secondaryFieldBoxBenchmarkSpeed.EntryText = ParseDoubleDefault(algorithm.SecondaryBenchmarkSpeed);
secondaryFieldBoxBenchmarkSpeed.Enabled = _currentlySelectedAlgorithm.SecondaryNiceHashID != AlgorithmType.NONE;
this.Update();
} else {
// TODO this should not be null
Expand All @@ -99,6 +107,7 @@ public void ChangeSpeed(ListViewItem lvi)
var algorithm = lvi.Tag as Algorithm;
if (algorithm != null) {
fieldBoxBenchmarkSpeed.EntryText = ParseDoubleDefault(algorithm.BenchmarkSpeed);
secondaryFieldBoxBenchmarkSpeed.EntryText = ParseDoubleDefault(algorithm.SecondaryBenchmarkSpeed);
}
}
}
Expand All @@ -113,10 +122,25 @@ private void textChangedBenchmarkSpeed(object sender, EventArgs e) {
double value;
if (Double.TryParse(fieldBoxBenchmarkSpeed.EntryText, out value)) {
_currentlySelectedAlgorithm.BenchmarkSpeed = value;
// update lvi speed
if (_currentlySelectedLvi != null) {
_currentlySelectedLvi.SubItems[2].Text = Helpers.FormatSpeedOutput(value);
}
}
updateSpeedText();
}

private void secondaryTextChangedBenchmarkSpeed(object sender, EventArgs e)
{
double secondaryValue;
if (Double.TryParse(secondaryFieldBoxBenchmarkSpeed.EntryText, out secondaryValue)) {
_currentlySelectedAlgorithm.SecondaryBenchmarkSpeed = secondaryValue;
}
updateSpeedText();
}

private void updateSpeedText()
{
var speedString = Helpers.FormatDualSpeedOutput(_currentlySelectedAlgorithm.BenchmarkSpeed, _currentlySelectedAlgorithm.SecondaryBenchmarkSpeed);
// update lvi speed
if (_currentlySelectedLvi != null) {
_currentlySelectedLvi.SubItems[2].Text = speedString;
}
}

Expand Down
2 changes: 1 addition & 1 deletion NiceHashMiner/Forms/Form_Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public void ClearRates(int groupCount) {
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) {
string ApiGetExceptionString = isApiGetException ? "**" : "";

string speedString = Helpers.FormatSpeedOutput(iAPIData.Speed) + iAPIData.AlgorithmName + ApiGetExceptionString;
string speedString = Helpers.FormatDualSpeedOutput(iAPIData.Speed, iAPIData.SecondarySpeed) + iAPIData.AlgorithmName + ApiGetExceptionString;
if (iAPIData.AlgorithmID == AlgorithmType.Equihash) {
speedString = speedString.Replace("H/s", "Sols/s");
}
Expand Down
2 changes: 1 addition & 1 deletion NiceHashMiner/Forms/Form_Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ private void checkBox_DisableDefaultOptimizations_CheckedChanged(object sender,
if (cDev.DeviceType == DeviceType.CPU) continue; // cpu has no defaults
var deviceDefaultsAlgoSettings = GroupAlgorithms.CreateForDeviceList(cDev);
foreach (var defaultAlgoSettings in deviceDefaultsAlgoSettings) {
var toSetAlgo = cDev.GetAlgorithm(defaultAlgoSettings.MinerBaseType, defaultAlgoSettings.NiceHashID);
var toSetAlgo = cDev.GetAlgorithm(defaultAlgoSettings.MinerBaseType, defaultAlgoSettings.NiceHashID, defaultAlgoSettings.SecondaryNiceHashID);
if (toSetAlgo != null) {
toSetAlgo.ExtraLaunchParameters = defaultAlgoSettings.ExtraLaunchParameters;
toSetAlgo.ExtraLaunchParameters = ExtraLaunchParametersParser.ParseForMiningPair(
Expand Down
Loading