Skip to content

Commit 368c834

Browse files
committed
TESTNET make it build (#1 no conflicting parts)
1 parent dc7f9c2 commit 368c834

17 files changed

+55
-190
lines changed

src/Miners/ClaymoreHub/ClaymoreHub.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
<Project>{279A5B29-3799-43FA-9734-E462E046BA81}</Project>
5050
<Name>NiceHashMinerLegacy.Common</Name>
5151
</ProjectReference>
52-
<ProjectReference Include="..\..\NiceHashMinerLegacy\NiceHashMinerLegacy.csproj">
53-
<Project>{A70B0AEE-15C4-49E1-9DC9-B936A1EBC2B5}</Project>
54-
<Name>NiceHashMinerLegacy</Name>
55-
</ProjectReference>
5652
<ProjectReference Include="..\MinerPluginToolkitV1\MinerPluginToolkitV1.csproj">
5753
<Project>{847398E0-2E35-4A85-8C70-0B40AA172ABA}</Project>
5854
<Name>MinerPluginToolkitV1</Name>

src/NiceHashMinerLegacy/ApplicationStateManager/ApplicationStateManager.Devices.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static partial class ApplicationStateManager
1616
#region device state checkers
1717
public static bool IsEnableAllDevicesRedundantOperation()
1818
{
19-
var allEnabled = ComputeDeviceManager.Available.Devices.All(dev => !dev.IsDisabled);
19+
var allEnabled = AvailableDevices.Devices.All(dev => !dev.IsDisabled);
2020
return allEnabled;
2121
}
2222

@@ -35,11 +35,11 @@ public static void SetDeviceEnabledState(object sender, (string uuid, bool enabl
3535
var isDisableAllDevices = "*" == uuid;
3636
if (isDisableAllDevices)
3737
{
38-
devicesToDisable.AddRange(ComputeDeviceManager.Available.Devices.Where(dev => !dev.IsDisabled));
38+
devicesToDisable.AddRange(AvailableDevices.Devices.Where(dev => !dev.IsDisabled));
3939
}
4040
else
4141
{
42-
var devWithUUID = ComputeDeviceManager.Available.GetDeviceWithUuidOrB64Uuid(uuid);
42+
var devWithUUID = AvailableDevices.GetDeviceWithUuidOrB64Uuid(uuid);
4343
if (devWithUUID != null)
4444
{
4545
devicesToDisable.Add(devWithUUID);

src/NiceHashMinerLegacy/ApplicationStateManager/ApplicationStateManager.Mining.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static string GetUsername()
2828

2929
private static void UpdateDevicesToMine()
3030
{
31-
var allDevs = ComputeDeviceManager.Available.Devices;
31+
var allDevs = AvailableDevices.Devices;
3232
var devicesToMine = allDevs.Where(dev => dev.State == DeviceState.Mining).ToList();
3333
if (devicesToMine.Count > 0) {
3434
StartMining();
@@ -43,7 +43,7 @@ private static void UpdateDevicesToMine()
4343
// TODO add check for any enabled algorithms
4444
public static (bool started, string failReason) StartAllAvailableDevices(bool isRpcCall = false)
4545
{
46-
var allDevs = ComputeDeviceManager.Available.Devices;
46+
var allDevs = AvailableDevices.Devices;
4747
var devicesToStart = allDevs.Where(dev => dev.State == DeviceState.Stopped);
4848
if (devicesToStart.Count() == 0) {
4949
return (false, "there are no new devices to start");
@@ -102,7 +102,7 @@ public static (bool started, string failReason) StartDevice(ComputeDevice device
102102
}
103103

104104
public static (bool stopped, string failReason) StopAllDevice() {
105-
var allDevs = ComputeDeviceManager.Available.Devices;
105+
var allDevs = AvailableDevices.Devices;
106106
// TODO when starting and stopping we are not taking Pending and Error states into account
107107
var devicesToStop = allDevs.Where(dev => dev.State == DeviceState.Mining || dev.State == DeviceState.Benchmarking);
108108
if (devicesToStop.Count() == 0) {

src/NiceHashMinerLegacy/ApplicationStateManager/ApplicationStateManager.Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static void Burn(string message)
5454
public static bool SystemRequirementsEnsured()
5555
{
5656
// check WMI
57-
if (!Helpers.IsWmiEnabled())
57+
if (!WindowsManagementObjectSearcher.IsWmiEnabled())
5858
{
5959
MessageBox.Show(Tr("NiceHash Miner Legacy cannot run needed components. It seems that your system has Windows Management Instrumentation service Disabled. In order for NiceHash Miner Legacy to work properly Windows Management Instrumentation service needs to be Enabled. This service is needed to detect RAM usage and Avaliable Video controler information. Enable Windows Management Instrumentation service manually and start NiceHash Miner Legacy."),
6060
Tr("Windows Management Instrumentation Error"),

src/NiceHashMinerLegacy/ApplicationStateManager/ApplicationStateManager.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private static void SetGroup(string groupName)
296296

297297
public static void ToggleActiveInactiveDisplay()
298298
{
299-
var allDevs = ComputeDeviceManager.Available.Devices;
299+
var allDevs = AvailableDevices.Devices;
300300
var devicesNotActive = allDevs.All(dev => dev.State != DeviceState.Mining && dev.State != DeviceState.Benchmarking);
301301
if (devicesNotActive)
302302
{
@@ -310,7 +310,7 @@ public static void ToggleActiveInactiveDisplay()
310310

311311
public static bool AnyInMiningState()
312312
{
313-
var allDevs = ComputeDeviceManager.Available.Devices;
313+
var allDevs = AvailableDevices.Devices;
314314
return allDevs.Any(dev => dev.State == DeviceState.Mining);
315315
}
316316

@@ -375,7 +375,7 @@ public static RigStatus CalcRigStatus()
375375
// TODO check if we are connected to ws if not retrun offline state
376376

377377
// check devices
378-
var allDevs = ComputeDeviceManager.Available.Devices;
378+
var allDevs = AvailableDevices.Devices;
379379
// now assume we have all disabled
380380
var rigState = RigStatus.Disabled;
381381
// order matters, we are excluding pending state

src/NiceHashMinerLegacy/Benchmarking/BenchmarkHandler2.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
// PRODUCTION
2+
#if !(TESTNET || TESTNETDEV)
3+
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46
using System.Text;
@@ -200,3 +202,4 @@ public void InvokeQuit()
200202
}
201203
}
202204
}
205+
#endif

src/NiceHashMinerLegacy/Benchmarking/BenchmarkHandler_testnet.cs

+3-82
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ public class BenchmarkHandler : IBenchmarkComunicator
2424
private Algorithm _currentAlgorithm;
2525
private Miner _currentMiner;
2626
private readonly BenchmarkPerformanceType _performanceType;
27-
private ClaymoreZcashBenchHelper _claymoreZcashStatus;
28-
29-
private CpuBenchHelper _cpuBenchmarkStatus;
3027

3128
private readonly PowerHelper _powerHelper;
3229

@@ -69,44 +66,6 @@ void IBenchmarkComunicator.OnBenchmarkComplete(bool success, string status)
6966
if (!BenchmarkManager.InBenchmark) return;
7067

7168
var rebenchSame = false;
72-
if (success && _cpuBenchmarkStatus != null && _cpuAlgos.Contains(_currentAlgorithm.NiceHashID) &&
73-
_currentAlgorithm.MinerBaseType == MinerBaseType.XmrStak)
74-
{
75-
_cpuBenchmarkStatus.SetNextSpeed(_currentAlgorithm.BenchmarkSpeed);
76-
rebenchSame = _cpuBenchmarkStatus.HasTest();
77-
_currentAlgorithm.LessThreads = _cpuBenchmarkStatus.LessTreads;
78-
if (rebenchSame == false)
79-
{
80-
_cpuBenchmarkStatus.FindFastest();
81-
_currentAlgorithm.BenchmarkSpeed = _cpuBenchmarkStatus.GetBestSpeed();
82-
_currentAlgorithm.LessThreads = _cpuBenchmarkStatus.GetLessThreads();
83-
}
84-
}
85-
86-
if (_claymoreZcashStatus != null && _currentAlgorithm.MinerBaseType == MinerBaseType.Claymore &&
87-
_currentAlgorithm.NiceHashID == AlgorithmType.Equihash)
88-
{
89-
if (_claymoreZcashStatus.HasTest())
90-
{
91-
_currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm);
92-
rebenchSame = true;
93-
//System.Threading.Thread.Sleep(1000*60*5);
94-
_claymoreZcashStatus.SetSpeed(_currentAlgorithm.BenchmarkSpeed);
95-
_claymoreZcashStatus.SetNext();
96-
_currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetTestExtraParams();
97-
Helpers.ConsolePrint("ClaymoreAMD_Equihash", _currentAlgorithm.ExtraLaunchParameters);
98-
_currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm));
99-
}
100-
101-
if (_claymoreZcashStatus.HasTest() == false)
102-
{
103-
rebenchSame = false;
104-
// set fastest mode
105-
_currentAlgorithm.BenchmarkSpeed = _claymoreZcashStatus.GetFastestTime();
106-
_currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetFastestExtraParams();
107-
}
108-
}
109-
11069
var power = _powerHelper.Stop();
11170

11271
var dualAlgo = _currentAlgorithm as DualAlgorithm;
@@ -141,18 +100,9 @@ void IBenchmarkComunicator.OnBenchmarkComplete(bool success, string status)
141100
{
142101
_powerHelper.Start();
143102

144-
if (_cpuBenchmarkStatus != null)
145-
{
146-
_currentMiner.BenchmarkStart(_cpuBenchmarkStatus.Time, this);
147-
}
148-
else if (_claymoreZcashStatus != null)
103+
if (dualAlgo != null && dualAlgo.TuningEnabled)
149104
{
150-
_currentMiner.BenchmarkStart(_claymoreZcashStatus.Time, this);
151-
}
152-
else if (dualAlgo != null && dualAlgo.TuningEnabled)
153-
{
154-
var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
155-
.GetBenchamrktime(_performanceType, Device.DeviceGroupType);
105+
var time = BenchmarkTimes.GetTime(_performanceType, Device.DeviceType);
156106
_currentMiner.BenchmarkStart(time, this);
157107
}
158108
}
@@ -178,43 +128,14 @@ private void NextBenchmark()
178128
if (Device != null && _currentAlgorithm != null)
179129
{
180130
_currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm);
181-
/*
182-
if (_currentAlgorithm.MinerBaseType == MinerBaseType.XmrStak && _currentAlgorithm.NiceHashID == AlgorithmType.CryptoNight
183-
&& string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters)
184-
&& _currentAlgorithm.ExtraLaunchParameters.Contains("enable_ht=true") == false) {
185-
_cpuBenchmarkStatus = new CPUBenchmarkStatus(Globals.ThreadsPerCPU);
186-
_currentAlgorithm.LessThreads = _cpuBenchmarkStatus.LessTreads;
187-
} else {
188-
_cpuBenchmarkStatus = null;
189-
}
190-
*/
191-
_cpuBenchmarkStatus = null;
192-
193-
if (_currentAlgorithm.MinerBaseType == MinerBaseType.Claymore &&
194-
_currentAlgorithm.NiceHashID == AlgorithmType.Equihash &&
195-
_currentAlgorithm.ExtraLaunchParameters != null &&
196-
!_currentAlgorithm.ExtraLaunchParameters.Contains("-asm"))
197-
{
198-
_claymoreZcashStatus = new ClaymoreZcashBenchHelper(_currentAlgorithm.ExtraLaunchParameters);
199-
_currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetTestExtraParams();
200-
}
201-
else
202-
{
203-
_claymoreZcashStatus = null;
204-
}
205-
206131
if (_currentAlgorithm is DualAlgorithm dualAlgo && dualAlgo.TuningEnabled) dualAlgo.StartTuning();
207132
}
208133

209134
if (_currentMiner != null && _currentAlgorithm != null && Device != null)
210135
{
211136
_currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm));
212137

213-
var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
214-
.GetBenchamrktime(_performanceType, Device.DeviceGroupType);
215-
//currentConfig.TimeLimit = time;
216-
if (_cpuBenchmarkStatus != null) _cpuBenchmarkStatus.Time = time;
217-
if (_claymoreZcashStatus != null) _claymoreZcashStatus.Time = time;
138+
var time = BenchmarkTimes.GetTime(_performanceType, Device.DeviceType);
218139

219140
// dagger about 4 minutes
220141
//var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

src/NiceHashMinerLegacy/Benchmarking/BenchmarkManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public static void Stop()
256256
private static void End()
257257
{
258258
InBenchmark = false;
259-
Ethlargement.Stop();
259+
EthlargementOld.Stop();
260260
_benchForm?.EndBenchmark(_hasFailedAlgorithms);
261261
}
262262

src/NiceHashMinerLegacy/Forms/Components/DevicesListViewBenchmarkControl.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected override void ListViewDevices_MouseClick(object sender, MouseEventArgs
124124
if (listViewDevices.FocusedItem.Tag is ComputeDevice cDevice)
125125
{
126126
var sameDevTypes =
127-
ComputeDeviceManager.Available.GetSameDevicesTypeAsDeviceWithUuid(cDevice.Uuid);
127+
AvailableDevices.GetSameDevicesTypeAsDeviceWithUuid(cDevice.Uuid);
128128
if (sameDevTypes.Count > 0)
129129
{
130130
var copyBenchItem = new ToolStripMenuItem();
@@ -167,7 +167,7 @@ protected override void ListViewDevices_MouseClick(object sender, MouseEventArgs
167167
private void ToolStripMenuItem_Click(object sender, bool justTuning) {
168168
if (sender is ToolStripMenuItem item && item.Tag is string uuid
169169
&& listViewDevices.FocusedItem.Tag is ComputeDevice CDevice) {
170-
var copyBenchCDev = ComputeDeviceManager.Available.GetDeviceWithUuid(uuid);
170+
var copyBenchCDev = AvailableDevices.GetDeviceWithUuid(uuid);
171171

172172
var result = MessageBox.Show(
173173
string.Format(

src/NiceHashMinerLegacy/Forms/Components/DevicesMainBoard.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private void DevicesDataGridView_CellContentClick(object sender, DataGridViewCel
115115
switch (cellItem)
116116
{
117117
case DataGridViewButtonCell button:
118-
var dev = ComputeDeviceManager.Available.GetDeviceWithUuidOrB64Uuid(deviceUUID);
118+
var dev = AvailableDevices.GetDeviceWithUuidOrB64Uuid(deviceUUID);
119119
if (dev == null) return;
120120
if (dev.State == DeviceState.Stopped) {
121121
button.Value = Tr("Starting");
@@ -146,7 +146,7 @@ void IDevicesStateDisplayer.RefreshDeviceListView(object sender, EventArgs _)
146146
// see what devices to
147147
// iterate each row
148148
var devicesToAddUuids = new List<string>();
149-
var allDevs = ComputeDeviceManager.Available.Devices;
149+
var allDevs = AvailableDevices.Devices;
150150
foreach (var dev in allDevs)
151151
{
152152
bool found = false;
@@ -164,7 +164,7 @@ void IDevicesStateDisplayer.RefreshDeviceListView(object sender, EventArgs _)
164164
}
165165

166166
// filter what to add if any
167-
var devsToAdd = ComputeDeviceManager.Available.Devices.Where(dev => devicesToAddUuids.Contains(dev.Uuid));
167+
var devsToAdd = AvailableDevices.Devices.Where(dev => devicesToAddUuids.Contains(dev.Uuid));
168168
foreach (var dev in devsToAdd)
169169
{
170170
// add dummy data
@@ -177,7 +177,7 @@ void IDevicesStateDisplayer.RefreshDeviceListView(object sender, EventArgs _)
177177
foreach (DataGridViewRow row in devicesDataGridView.Rows)
178178
{
179179
var tagUUID = (string)row.Tag;
180-
var dev = ComputeDeviceManager.Available.Devices.FirstOrDefault(d => d.Uuid == tagUUID);
180+
var dev = AvailableDevices.Devices.FirstOrDefault(d => d.Uuid == tagUUID);
181181
SetRowColumnItemValue(row, Column.Enabled, dev.Enabled);
182182
SetRowColumnItemValue(row, Column.Name, dev.GetFullName());
183183
SetRowColumnItemValue(row, Column.Status, stateStr(dev.State));

src/NiceHashMinerLegacy/Forms/FormHelpers_production.cs src/NiceHashMinerLegacy/Forms/FormHelpers_shared.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// PRODUCTION
2-
#if !(TESTNET || TESTNETDEV)
1+
// SHARED - PRODUCTION + TESTNET / TESTNETDEV
32

43
using System;
54
using System.Collections.Generic;
@@ -10,7 +9,7 @@
109

1110
namespace NiceHashMiner.Forms
1211
{
13-
public static class FormHelpers
12+
public static partial class FormHelpers
1413
{
1514

1615
public static void TranslateFormControls(Control c)
@@ -85,4 +84,3 @@ static public void SafeInvoke(this Control c, Action f, bool beginInvoke = false
8584
}
8685
}
8786
}
88-
#endif

src/NiceHashMinerLegacy/Forms/FormHelpers_testnet.cs

+2-21
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,9 @@
1111

1212
namespace NiceHashMiner.Forms
1313
{
14-
static class FormHelpers
14+
public static partial class FormHelpers
1515
{
16-
// TODO maybe not the best name
17-
static public void SafeInvoke(Control c, Action f, bool beginInvoke = false)
18-
{
19-
if (c.InvokeRequired)
20-
{
21-
if (beginInvoke)
22-
{
23-
c.BeginInvoke(f);
24-
}
25-
else
26-
{
27-
c.Invoke(f);
28-
}
29-
}
30-
else
31-
{
32-
f();
33-
}
34-
}
35-
16+
3617
static public void SubscribeAllControls(Control c)
3718
{
3819
// data display

0 commit comments

Comments
 (0)