Skip to content

Commit

Permalink
fix broken period switching
Browse files Browse the repository at this point in the history
  • Loading branch information
angelbbs committed Jul 16, 2021
1 parent ea6dee3 commit 6b5ce41
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
Binary file modified LatestBuild/nhmlffLatest.zip
Binary file not shown.
10 changes: 9 additions & 1 deletion NiceHashMiner/Miners/MiningSession.cs
Expand Up @@ -538,11 +538,19 @@ public void SwichMostProfitableGroupUpMethod(object sender, SmaUpdateEventArgs e
}
else
{
if (AlgorithmSwitchingManager.newProfit)
{
needSwitch = true;
Helpers.ConsolePrint(Tag,
$"Will SWITCH profit diff is {Math.Round(percDiff * 100, 2)}%, current threshold {ConfigManager.GeneralConfig.SwitchProfitabilityThreshold * 100}%");
} else
{
needSwitch = true;
Helpers.ConsolePrint(Tag,$"Will NOT SWITCH. Switching period has not been exceeded");
}

}
}
}
else
{
foreach (var device in _miningDevices)
Expand Down
13 changes: 10 additions & 3 deletions NiceHashMiner/Stats/NiceHashStats.cs
Expand Up @@ -99,6 +99,7 @@ public class ExchangeRateJson
public static bool remoteMiningStart = false;
public static bool remoteMiningStop = false;
public static bool remoteUpdateUI = false;
private static bool DeviceStatusRunning = false;

private static void LoadCachedSMAData()
{
Expand All @@ -120,11 +121,11 @@ private static void LoadCachedSMAData()

public static void StartConnection(string address)
{
NHSmaData.InitializeIfNeeded();
LoadCachedSMAData();


try
{
NHSmaData.InitializeIfNeeded();
LoadCachedSMAData();
_socket = null;
_socket = new NiceHashSocket(address);

Expand Down Expand Up @@ -1135,6 +1136,9 @@ public static void DeviceStatus_TickNew(object sender, ElapsedEventArgs e)
}
public static async void SetDeviceStatus(object state, bool devName = false)
{
Helpers.ConsolePrint("SOCKET", "DeviceStatusRunning: " + DeviceStatusRunning);
if (DeviceStatusRunning) return;
DeviceStatusRunning = true;
var devices = ComputeDeviceManager.Available.Devices;

var _computeDevicesResort = ComputeDeviceManager.ReSortDevices(devices);
Expand Down Expand Up @@ -1359,6 +1363,7 @@ public static async void SetDeviceStatus(object state, bool devName = false)
deviceList.Add(array);
}
catch (Exception ex) { Helpers.ConsolePrint("SOCKET", ex.ToString()); }
DeviceStatusRunning = false;
}

try
Expand All @@ -1380,7 +1385,9 @@ public static async void SetDeviceStatus(object state, bool devName = false)
catch (Exception ex)
{
throw new Exception($"DeviceStatus_TickNew: {ex.ToString()}");
DeviceStatusRunning = false;
}
DeviceStatusRunning = false;
}


Expand Down
6 changes: 3 additions & 3 deletions NiceHashMiner/Switching/AlgorithmSwitchingManager.cs
Expand Up @@ -137,7 +137,7 @@ public static void SmaCheckTimerOnElapsed(object sender, ElapsedEventArgs e)
SmaCheckTimerOnElapsedRun = true;

//if (_smaCheckTimer != null) _smaCheckTimer.Interval = _smaCheckTime * 1000;

GetTickPeriod();
var sb = new StringBuilder();
if (_hasStarted)
{
Expand Down Expand Up @@ -190,7 +190,7 @@ private static bool UpdateProfits(Dictionary<AlgorithmType, AlgorithmHistory> hi
if (i >= ticks || algo == AlgorithmType.DaggerHashimoto3GB || algo == AlgorithmType.DaggerHashimoto4GB)
{
_lastLegitPaying[algo] = paying;
sb.AppendLine($"\tTAKEN: new profit {paying:e5} after {i} {cTicks} for {algo}");
sb.AppendLine($"\tTAKEN: new profit {paying:e5} after {i}/{ticks} {cTicks} for {algo}");
newProfit = true;
}
else
Expand All @@ -213,7 +213,7 @@ private static bool UpdateProfits(Dictionary<AlgorithmType, AlgorithmHistory> hi
return updated;
}

private static void Randomize()
private static void GetTickPeriod()
{
// Lock in case this gets called simultaneously
// Random breaks down when called from multiple threads
Expand Down

0 comments on commit 6b5ce41

Please sign in to comment.