This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 322
/
Copy pathAlgorithm.cs
145 lines (130 loc) · 5.72 KB
/
Algorithm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using Newtonsoft.Json;
using NiceHashMiner.Enums;
using System;
using System.Collections.Generic;
using System.Text;
namespace NiceHashMiner {
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; }
// CPU miners only setting
public int LessThreads { get; set; }
// 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;
this.AlgorithmName = AlgorithmNiceHashNames.GetName(DualNiceHashID());
this.MinerBaseTypeName = Enum.GetName(typeof(MinerBaseType), minerBaseType);
this.AlgorithmStringID = this.MinerBaseTypeName + "_" + this.AlgorithmName;
MinerBaseType = minerBaseType;
MinerName = minerName;
BenchmarkSpeed = 0.0d;
SecondaryBenchmarkSpeed = 0.0d;
ExtraLaunchParameters = "";
LessThreads = 0;
Enabled = !IsDual();
BenchmarkStatus = "";
}
// benchmark info
public string BenchmarkStatus { get; set; }
public bool IsBenchmarkPending { get; private set; }
public string CurPayingRatio {
get {
string ratio = International.GetText("BenchmarkRatioRateN_A");
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");
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;
}
}
public void SetBenchmarkPending() {
IsBenchmarkPending = true;
BenchmarkStatus = International.GetText("Algorithm_Waiting_Benchmark");
}
public void SetBenchmarkPendingNoMsg() {
IsBenchmarkPending = true;
}
private bool IsPendingString() {
return BenchmarkStatus == International.GetText("Algorithm_Waiting_Benchmark")
|| BenchmarkStatus == "."
|| BenchmarkStatus == ".."
|| BenchmarkStatus == "...";
}
public void ClearBenchmarkPending() {
IsBenchmarkPending = false;
if (IsPendingString()) {
BenchmarkStatus = "";
}
}
public void ClearBenchmarkPendingFirst() {
IsBenchmarkPending = false;
BenchmarkStatus = "";
}
public string BenchmarkSpeedString() {
if (Enabled && IsBenchmarkPending && !string.IsNullOrEmpty(BenchmarkStatus)) {
return BenchmarkStatus;
} else if (BenchmarkSpeed > 0) {
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);
}
}
}