// , string miningLocation, string btcAdress, string worker public GroupMiner(List <MiningPair> miningPairs, string key) { AlgorithmType = AlgorithmType.NONE; DevicesInfoString = "N/A"; CurrentRate = 0; Key = key; if (miningPairs.Count > 0) { // sort pairs by device id miningPairs.Sort((a, b) => a.Device.ID - b.Device.ID); // init name scope { List <string> deviceNames = new List <string>(); foreach (var pair in miningPairs) { deviceNames.Add(pair.Device.NameCount); } DevicesInfoString = "{ " + String.Join(", ", deviceNames) + " }"; } // init miner { var mPair = miningPairs[0]; DeviceType = mPair.Device.DeviceType; Miner = MinerFactory.CreateMiner(mPair.Device, mPair.Algorithm); if (Miner != null) { Miner.InitMiningSetup(new MiningSetup(miningPairs)); AlgorithmType = mPair.Algorithm.NiceHashID; } } } }
/// <summary> /// Handler to create multiple mining sessions if needed /// </summary> private void SetupLocalMiners() { // This logic will be moved to a class to setup the local miners and add them to the mining session // This will be done via config file and API calls necessary based on the coins being mined, etc. MiningSession.RemoveAllMiners(); // Call API and retrieve a list of miner configurations used to start mining List <MinerConfigResponse> minerConfigResponseList = GetMinerConfigurations(); // Build the Request to call the API and retrieve the miner config strings List <AccountWallet> accountWalletList = new List <AccountWallet>(); // Get configurations needed for building API request from Application settings accountWalletList = (List <AccountWallet>)Application.Current.Properties["AccountWalletList"]; // Iterate through returned responses from API and initialize miners foreach (MinerConfigResponse minerConfigResponse in minerConfigResponseList) { // Create miner session Miner miner = MinerFactory.CreateMiner(minerConfigResponse.MinerBaseType, minerConfigResponse.HardwareType); miner.CoinType = minerConfigResponse.CoinSelectedForMining; miner.MinerArguments = minerConfigResponse.MinerConfigString; miner.Address = accountWalletList.Find(x => x.CoinType == miner.CoinType.ToString()).WalletAddress; MiningSession.AddMiner(miner); ShowInformation(string.Format("Mining started {0} {1}", minerConfigResponse.MinerBaseType, minerConfigResponse.MinerConfigString)); } }
private static void BenchmarkIfNeeded() { if (!Config.DisableBenchmarking) { WriteInfo(" Checking if benchmarking is needed.."); List <MiningConfig> configsToTest = new List <MiningConfig>(); foreach (Algorithm algorithm in Config.Algorithms) { if (algorithm.Enabled) { foreach (DeviceConfig deviceConfig in algorithm.DeviceConfigs) { if (deviceConfig.Enabled && deviceConfig.ExpectedHashrate <= 0) { configsToTest.Add(new MiningConfig(deviceConfig, algorithm.Pools.First(p => p.Enabled))); } } } } if (configsToTest.Count == 0) { WriteInfo(" Benchmarking not needed: All algorithm-device-combinations have a valid expected hashrate."); } else { WriteInfo(" Benchmarking needed: Not all algorithm-device-combinations have a valid expected hashrate."); Console.WriteLine(); WriteLineColor(" BENCHMARKING:", ConsoleColor.Cyan); foreach (MiningConfig miningConfig in configsToTest) { Console.WriteLine(); Console.Write(" Benchmarking "); WriteColor(miningConfig.DeviceConfig.FullDeviceId, ConsoleColor.Yellow); Console.Write(" on "); WriteColor(miningConfig.Pool.UniqueName, ConsoleColor.Yellow); Console.WriteLine(".."); IMiner miner = MinerFactory.GetMiner(new HashSet <DeviceConfig>() { miningConfig.DeviceConfig }, miningConfig.Pool); miner.StartMiner(Config.StartMinerMinimized); int userInputHashrate = 0; while (userInputHashrate <= 0) { Console.Write(" Please enter the hashrate: "); Console.CursorVisible = true; Console.ForegroundColor = ConsoleColor.Yellow; string input = Console.ReadLine(); Console.ResetColor(); int.TryParse(input, out userInputHashrate); } Console.CursorVisible = false; miningConfig.DeviceConfig.ExpectedHashrate = userInputHashrate; SaveConfig(); miner.StopMiner(); } } } }
static void Main(string[] args) { System.Console.WriteLine(BANNER); Console.WriteLine($@"BPM home directory: {Core.GetBPMBaseUserDirectory()}"); Console.WriteLine($@"BPM miners directory: {Core.GetBaseMinersDir()}"); var minerAccount = MinerAccount.Init(); var miningSession = new MiningSession(); miningSession.RemoveAllMiners(); System.Console.WriteLine($@"Account Id: {minerAccount.AccountId}"); System.Console.WriteLine($@"Region: {minerAccount.Region}"); System.Console.WriteLine($@"Worker: {minerAccount.WorkerSettings.WorkerName}"); System.Console.WriteLine(@"Configured Wallets:"); minerAccount.AccountWalletList.Select(w => $@" {w.CoinName}: {w.WalletAddress}") .ToList().ForEach(System.Console.WriteLine); // Call API and retrieve a list of miner configurations used to start mining List <MinerConfigResponse> minerConfigResponseList = GetMinerConfigurations(minerAccount); var hardwareMonitor = new LinuxHardwareMonitor(); var minerFactory = new MinerFactory(hardwareMonitor); // Iterate through returned responses from API and initialize miners foreach (MinerConfigResponse minerConfigResponse in minerConfigResponseList) { // Create miner session var miner = minerFactory.CreateMiner(minerConfigResponse.MinerBaseType, minerConfigResponse.HardwareType); miner.CoinType = minerConfigResponse.CoinSelectedForMining; miner.MinerArguments = minerConfigResponse.MinerConfigString; miningSession.AddMiner(miner); System.Console.WriteLine(string.Format("Mining started {0} {1}", minerConfigResponse.MinerBaseType, minerConfigResponse.MinerConfigString)); } System.Console.ReadLine(); }
public BlockValidationTests() { _address = new Address("test1".Hash()); _feedback = new NullFeedBack(); _cryptography = new Cryptography(); _minerFactory = new MinerFactory(_cryptography); _chainData = new ChainData(_feedback, _cryptography); }
private async Task BenchmarkAlgorithm(Algorithm algo) { var currentMiner = MinerFactory.CreateMiner(Device, algo); if (currentMiner == null) { return; } _benchmarkForm.AddToStatusCheck(Device, algo); if (algo is DualAlgorithm dualAlgo && dualAlgo.TuningEnabled && dualAlgo.StartTuning()) { await BenchmarkAlgorithmDual(currentMiner, dualAlgo); }
private static void StartMiner(Mineable mineable, Settings settings, string appRoot, DirectoryInfo appRootFolder) { var differenceToLastProfitSwitch = DateTimeOffset.Now.Subtract(_lastProfitSwitch).TotalSeconds; if (differenceToLastProfitSwitch > settings.ProfitSwitchCooldown) { StopMiner(); _currentMineable = mineable; ExecuteScript(mineable.PrepareScript, appRoot); _currentMiner = MinerFactory.GetMiner(mineable.Miner); _lastProfitSwitch = DateTimeOffset.Now; try { Log.Information($"Starting {_currentMiner.Name} with {mineable.DisplayName}."); _currentMiner.StartMiner(mineable, settings, appRoot, appRootFolder); } catch (Exception ex) { Log.Warning("Couldn't start miner: " + ex); ResetApp(settings, appRoot, false); } if (_manualWatchdogEnabled.HasValue) { if (_manualWatchdogEnabled.Value) { _watchdogCts?.Cancel(); _watchdogCts = new CancellationTokenSource(); var watchdogTask = WatchdogTaskAsync(settings, appRoot, appRootFolder, _watchdogCts.Token); } } else { if (settings.EnableWatchdog) { _watchdogCts?.Cancel(); _watchdogCts = new CancellationTokenSource(); var watchdogTask = WatchdogTaskAsync(settings, appRoot, appRootFolder, _watchdogCts.Token); } } } else { Console.WriteLine($"Didn't switched to {mineable.DisplayName}! Waiting {settings.ProfitSwitchCooldown} seconds to cooldown."); } }
private async Task BenchmarkAlgorithm(Algorithm algo) { var currentMiner = MinerFactory.CreateMinerForBenchmark(algo); if (currentMiner == null) { return; } BenchmarkManager.AddToStatusCheck(Device, algo); if (algo is PluginAlgorithm pAlgo) { await BenchmarkPluginAlgorithm(pAlgo); } }
private void NextBenchmark() { ++_benchmarkCurrentIndex; if (_benchmarkCurrentIndex > 0) { _benchmarkForm.StepUpBenchmarkStepProgress(); } if (_benchmarkCurrentIndex >= _benchmarkAlgorithmsCount) { EndBenchmark(); return; } if (_benchmarkAlgorithmQueue.Count > 0) { _currentAlgorithm = _benchmarkAlgorithmQueue.Dequeue(); } if (Device != null && _currentAlgorithm != null) { _currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm); if (_currentAlgorithm is DualAlgorithm dualAlgo && dualAlgo.TuningEnabled) { dualAlgo.StartTuning(); } } if (_currentMiner != null && _currentAlgorithm != null && Device != null) { _currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm)); var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits .GetBenchamrktime(_performanceType, Device.DeviceGroupType); //currentConfig.TimeLimit = time; // dagger about 4 minutes //var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time; _benchmarkForm.AddToStatusCheck(Device, _currentAlgorithm); _currentMiner.BenchmarkStart(time, this); _powerHelper.Start(); } else { NextBenchmark(); } }
public void CreateMinerTest() { var field = new Field(); var miner = MinerFactory.CreateMiner("Alpha Miner", field); Assert.IsInstanceOfType(miner, typeof(AlphaMiner)); miner = MinerFactory.CreateMiner("Heuristic Miner", field); Assert.IsInstanceOfType(miner, typeof(HeuristicMiner)); MinerSettings.ListOfMinerSettings["InductiveMiner"] = "InductiveMiner"; miner = MinerFactory.CreateMiner("Inductive Miner", field); Assert.IsInstanceOfType(miner, typeof(InductiveMiner)); MinerSettings.ListOfMinerSettings["InductiveMiner"] = "InductiveMinerInfrequent"; miner = MinerFactory.CreateMiner("Inductive Miner", field); Assert.IsInstanceOfType(miner, typeof(InductiveMinerInfrequent)); }
/// <summary> /// Start the miner on a list of fields and save the results in a dictionary /// </summary> /// <param name="fields"></param> /// <author>Bernhard Bruns</author> public void Mine(List <Field> fields) { int fieldCounter = 1; Parallel.ForEach(fields, field => { try { field.ResetInformation(); IMiner iMiner = MinerFactory.CreateMiner(MinerSettings.MinerName, field); ProcessModel resultingProcessModel = iMiner.Mine(); // Save petrinet in the field object field.ProcessModel = resultingProcessModel; Dispatcher.BeginInvoke((Action)(() => { MiningInfo.BBCode += "\n[b]Mining field " + fieldCounter++ + " of " + fields.Count + "[/b]" + "\n[color=#00E600]Successfully mined.[/color]"; MiningInfoScrollViewer.ScrollToEnd(); })).Wait(); } catch (ArgumentNullException Ex) { Dispatcher.BeginInvoke((Action)(() => { MiningInfo.BBCode += "\n[b]Mining field " + fieldCounter++ + " of " + fields.Count + "[/b]" + "\nERROR: Parameter " + Ex.ParamName + " was not given:\n" + Ex.Message; MiningInfoScrollViewer.ScrollToEnd(); })).Wait(); } catch (Exception Ex) { Dispatcher.BeginInvoke((Action)(() => { MiningInfo.BBCode += "\n[b]Mining field " + fieldCounter++ + " of " + fields.Count + "[/b]" + "\n[color=#FF0000]ERROR: [/color]" + Ex.Message; MiningInfoScrollViewer.ScrollToEnd(); })).Wait(); } finally { Dispatcher.BeginInvoke((Action)(() => { ProgressBar.Value += 1; })).Wait(); _parallelOption.CancellationToken.ThrowIfCancellationRequested(); } }); }
/// <summary> /// Handler to create multiple mining sessions if needed /// </summary> private void SetupLocalMiners() { // This logic will be moved to a class to setup the local miners and add them to the mining session // This will be done via config file and API calls necessary based on the coins being mined, etc. MiningSession.RemoveAllMiners(); // Call API and retrieve a list of miner configurations used to start mining List <MinerConfigResponse> minerConfigResponseList = GetMinerConfigurations(); // Iterate through returned responses from API and initialize miners var minerFactory = new MinerFactory(new WindowsHardwareMonitor()); foreach (MinerConfigResponse minerConfigResponse in minerConfigResponseList) { // Create miner session var miner = minerFactory.CreateMiner(minerConfigResponse.MinerBaseType, minerConfigResponse.HardwareType); miner.CoinType = minerConfigResponse.CoinSelectedForMining; miner.MinerArguments = minerConfigResponse.MinerConfigString; MiningSession.AddMiner(miner); ShowInformation(string.Format("Mining started {0} {1}", minerConfigResponse.MinerBaseType, minerConfigResponse.MinerConfigString)); } }
public void OnBenchmarkComplete(bool success, string status) { if (!_benchmarkForm.InBenchmark) { return; } var rebenchSame = false; if (success && _cpuBenchmarkStatus != null && _cpuAlgos.Contains(_currentAlgorithm.NiceHashID) && _currentAlgorithm.MinerBaseType == MinerBaseType.XmrStak) { _cpuBenchmarkStatus.SetNextSpeed(_currentAlgorithm.BenchmarkSpeed); rebenchSame = _cpuBenchmarkStatus.HasTest(); _currentAlgorithm.LessThreads = _cpuBenchmarkStatus.LessTreads; if (rebenchSame == false) { _cpuBenchmarkStatus.FindFastest(); _currentAlgorithm.BenchmarkSpeed = _cpuBenchmarkStatus.GetBestSpeed(); _currentAlgorithm.LessThreads = _cpuBenchmarkStatus.GetLessThreads(); } } if (_claymoreZcashStatus != null && _currentAlgorithm.MinerBaseType == MinerBaseType.Claymore && _currentAlgorithm.NiceHashID == AlgorithmType.Equihash) { if (_claymoreZcashStatus.HasTest()) { _currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm); rebenchSame = true; //System.Threading.Thread.Sleep(1000*60*5); _claymoreZcashStatus.SetSpeed(_currentAlgorithm.BenchmarkSpeed); _claymoreZcashStatus.SetNext(); _currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetTestExtraParams(); Helpers.ConsolePrint("ClaymoreAMD_Equihash", _currentAlgorithm.ExtraLaunchParameters); _currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm)); } if (_claymoreZcashStatus.HasTest() == false) { rebenchSame = false; // set fastest mode _currentAlgorithm.BenchmarkSpeed = _claymoreZcashStatus.GetFastestTime(); _currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetFastestExtraParams(); } } var power = _powerHelper.Stop(); var dualAlgo = _currentAlgorithm as DualAlgorithm; if (dualAlgo != null && dualAlgo.TuningEnabled) { dualAlgo.SetPowerForCurrent(power); if (dualAlgo.IncrementToNextEmptyIntensity()) { rebenchSame = true; } } else { _currentAlgorithm.PowerUsage = power; } if (!rebenchSame) { _benchmarkForm.RemoveFromStatusCheck(Device, _currentAlgorithm); } if (!success && !rebenchSame) { // add new failed list _benchmarkFailedAlgo.Add(_currentAlgorithm.AlgorithmName); _benchmarkForm.SetCurrentStatus(Device, _currentAlgorithm, status); } else if (!rebenchSame) { // set status to empty string it will return speed _currentAlgorithm.ClearBenchmarkPending(); _benchmarkForm.SetCurrentStatus(Device, _currentAlgorithm, ""); } if (rebenchSame) { _powerHelper.Start(); if (_cpuBenchmarkStatus != null) { _currentMiner.BenchmarkStart(_cpuBenchmarkStatus.Time, this); } else if (_claymoreZcashStatus != null) { _currentMiner.BenchmarkStart(_claymoreZcashStatus.Time, this); } else if (dualAlgo != null && dualAlgo.TuningEnabled) { var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits .GetBenchamrktime(_performanceType, Device.DeviceGroupType); _currentMiner.BenchmarkStart(time, this); } } else { NextBenchmark(); } }
private void NextBenchmark() { ++_benchmarkCurrentIndex; if (_benchmarkCurrentIndex > 0) { _benchmarkForm.StepUpBenchmarkStepProgress(); } if (_benchmarkCurrentIndex >= _benchmarkAlgorithmsCount) { EndBenchmark(); return; } if (_benchmarkAlgorithmQueue.Count > 0) { _currentAlgorithm = _benchmarkAlgorithmQueue.Dequeue(); } if (Device != null && _currentAlgorithm != null) { _currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm); /* * if (_currentAlgorithm.MinerBaseType == MinerBaseType.XmrStak && _currentAlgorithm.NiceHashID == AlgorithmType.CryptoNight * && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters) * && _currentAlgorithm.ExtraLaunchParameters.Contains("enable_ht=true") == false) { * _cpuBenchmarkStatus = new CPUBenchmarkStatus(Globals.ThreadsPerCPU); * _currentAlgorithm.LessThreads = _cpuBenchmarkStatus.LessTreads; * } else { * _cpuBenchmarkStatus = null; * } */ _cpuBenchmarkStatus = null; if (_currentAlgorithm.MinerBaseType == MinerBaseType.Claymore && _currentAlgorithm.NiceHashID == AlgorithmType.Equihash && _currentAlgorithm.ExtraLaunchParameters != null && !_currentAlgorithm.ExtraLaunchParameters.Contains("-asm")) { _claymoreZcashStatus = new ClaymoreZcashBenchHelper(_currentAlgorithm.ExtraLaunchParameters); _currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetTestExtraParams(); } else { _claymoreZcashStatus = null; } if (_currentAlgorithm is DualAlgorithm dualAlgo && dualAlgo.TuningEnabled) { dualAlgo.StartTuning(); } } if (_currentMiner != null && _currentAlgorithm != null && Device != null) { _currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm)); var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits .GetBenchamrktime(_performanceType, Device.DeviceGroupType); //currentConfig.TimeLimit = time; if (_cpuBenchmarkStatus != null) { _cpuBenchmarkStatus.Time = time; } if (_claymoreZcashStatus != null) { _claymoreZcashStatus.Time = time; } // dagger about 4 minutes //var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time; _benchmarkForm.AddToStatusCheck(Device, _currentAlgorithm); _currentMiner.BenchmarkStart(time, this); _powerHelper.Start(); } else { NextBenchmark(); } }
private async Task BenchmarkAlgorithm(/*Algorithm algo*/) { // fix naming var _currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm); if (_currentMiner == null) { return; } // well lets just assume it is not null // actual benchmarking scope? { _benchmarkForm.AddToStatusCheck(Device, _currentAlgorithm); // TODO add the multiple benchmark loop _currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm)); var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits .GetBenchamrktime(_performanceType, Device.DeviceGroupType); ////currentConfig.TimeLimit = time; //if (_cpuBenchmarkStatus != null) _cpuBenchmarkStatus.Time = time; //if (_claymoreZcashStatus != null) _claymoreZcashStatus.Time = time; // dagger about 4 minutes //var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time; var benchTaskResult = _currentMiner.BenchmarkStartAsync(time, _stopBenchmark.Token); _powerHelper.Start(); var result = await benchTaskResult; var power = _powerHelper.Stop(); var rebenchSame = false; // TODO get rid of this, but keep for DualAlgorithm's for now var dualAlgo = _currentAlgorithm as DualAlgorithm; if (dualAlgo != null && dualAlgo.TuningEnabled) { dualAlgo.SetPowerForCurrent(power); if (dualAlgo.IncrementToNextEmptyIntensity()) { rebenchSame = true; } } else { _currentAlgorithm.PowerUsage = power; } if (!rebenchSame) { _benchmarkForm.RemoveFromStatusCheck(Device, _currentAlgorithm); } if (!result.Success && !rebenchSame) { // add new failed list _benchmarkFailedAlgo.Add(_currentAlgorithm.AlgorithmName); _benchmarkForm.SetCurrentStatus(Device, _currentAlgorithm, result.Status); } else if (!rebenchSame) { // set status to empty string it will return speed _currentAlgorithm.ClearBenchmarkPending(); _benchmarkForm.SetCurrentStatus(Device, _currentAlgorithm, ""); } } }
private static void CheckSwitching() { try { WriteInfo(" Check switching.."); IProfitSwitchingStrategy profitSwitchingStrategy = ProfitSwitchingStrategyFactory.GetProfitSwitchingStrategy(_profitSwitchingStrategy ?? ProfitSwitchingStrategy.MaximizeFiat); // Find optimal configs Dictionary <string, MiningConfig> optimalMiningConfigs = new Dictionary <string, MiningConfig>(); if (_manualMode) { foreach (var manualMininigConfig in _manualMininigConfigs) { MiningConfig miningConfig = new MiningConfig(manualMininigConfig.Value.DeviceConfig, manualMininigConfig.Value.Pool); optimalMiningConfigs.Add(manualMininigConfig.Key, miningConfig); } } else { foreach (Algorithm algorithm in Config.Algorithms) { if (algorithm.Enabled) { foreach (DeviceConfig algorithmDeviceConfig in algorithm.DeviceConfigs) { if (algorithmDeviceConfig.Enabled) { foreach (Pool algorithmPool in algorithm.Pools.Where(p => p.Enabled)) { Profit?profit = GetAdjustedProfit(algorithmPool, algorithmDeviceConfig.ExpectedHashrate, true); if (profit.HasValue) { if (!optimalMiningConfigs.ContainsKey(algorithmDeviceConfig.FullDeviceId)) { SetOptimalMiningConfigWithThreshold(profit.Value, profitSwitchingStrategy, algorithmDeviceConfig, algorithmPool, optimalMiningConfigs); } else { MiningConfig bestMiningConfig = optimalMiningConfigs[algorithmDeviceConfig.FullDeviceId]; Profit? bestProfit = GetAdjustedProfit(bestMiningConfig.Pool, bestMiningConfig.DeviceConfig.ExpectedHashrate, true); if (!bestProfit.HasValue || profitSwitchingStrategy.IsProfitABetterThanB(profit.Value, algorithmPool.ProfitTimeframe, bestProfit.Value, bestMiningConfig.Pool.ProfitTimeframe, 0)) { SetOptimalMiningConfigWithThreshold(profit.Value, profitSwitchingStrategy, algorithmDeviceConfig, algorithmPool, optimalMiningConfigs); } } } } } } } } } // Merge miners and get list of optimal miners List <IMiner> optimalMiners = new List <IMiner>(); foreach (var optimalMiningConfigKeyValue in optimalMiningConfigs) { MiningConfig miningConfig = optimalMiningConfigKeyValue.Value; IMiner miner = MinerFactory.GetMiner(new HashSet <DeviceConfig>() { miningConfig.DeviceConfig }, miningConfig.Pool); IMiner existingMiner = optimalMiners.FirstOrDefault(m => m.Name == miner.Name && m.Pool.Equals(miner.Pool)); if (existingMiner != null) { existingMiner.DeviceConfigs.Add(miningConfig.DeviceConfig); miningConfig.Miner = existingMiner; } else { miningConfig.Miner = miner; optimalMiners.Add(miner); } } bool displayNeedsUpdate = false; // Get list of current miners List <IMiner> currentMiners = GetCurrentMiners(); //Check if existing miner will be kept foreach (IMiner currentMiner in currentMiners) { if (optimalMiners.Any(om => om.Pool.Equals(currentMiner.Pool) && om.DeviceConfigs.SetEquals(currentMiner.DeviceConfigs))) { foreach (DeviceConfig currentMinerDeviceConfig in currentMiner.DeviceConfigs) { optimalMiningConfigs[currentMinerDeviceConfig.FullDeviceId].Miner = currentMiner; } } } //Check if existing miner has to be closed foreach (IMiner currentMiner in currentMiners.ToArray()) { if (!optimalMiners.Any(om => om.Pool.Equals(currentMiner.Pool) && om.DeviceConfigs.SetEquals(currentMiner.DeviceConfigs))) { displayNeedsUpdate = true; currentMiner.StopMiner(); currentMiners.Remove(currentMiner); } } //Check if new miner has to start foreach (IMiner optimalMiner in optimalMiners) { if (!currentMiners.Any(cm => cm.Pool.Equals(optimalMiner.Pool) && cm.DeviceConfigs.SetEquals(optimalMiner.DeviceConfigs))) { displayNeedsUpdate = true; foreach (DeviceConfig deviceConfig in optimalMiner.DeviceConfigs) { if (!string.IsNullOrEmpty(deviceConfig.PrepareScript)) { Helpers.ExecuteScript(deviceConfig.MinerPath, AppFolderPath); } } Task.Delay(TimeSpan.FromSeconds(Config.MinerStartDelay)).Wait(); optimalMiner.StartMiner(Config.StartMinerMinimized); } } _currentMininigConfigs = optimalMiningConfigs; if (displayNeedsUpdate) { _displayUpdaterCts?.Cancel(); } } catch (Exception e) { Log.Debug("Check switching failed: " + e); } }
public void OnBenchmarkComplete(bool success, string status) { if (!_inBenchmark) { return; } this.Invoke((MethodInvoker) delegate { _bechmarkedSuccessCount += success ? 1 : 0; bool rebenchSame = false; if (success && __CPUBenchmarkStatus != null && CPUAlgos.Contains(_currentAlgorithm.NiceHashID) && _currentAlgorithm.MinerBaseType == MinerBaseType.XmrStackCPU) { __CPUBenchmarkStatus.SetNextSpeed(_currentAlgorithm.BenchmarkSpeed); rebenchSame = __CPUBenchmarkStatus.HasTest(); _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.LessTreads; if (rebenchSame == false) { __CPUBenchmarkStatus.FindFastest(); _currentAlgorithm.BenchmarkSpeed = __CPUBenchmarkStatus.GetBestSpeed(); _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.GetLessThreads(); } } if (__ClaymoreZcashStatus != null && _currentAlgorithm.MinerBaseType == MinerBaseType.Claymore && _currentAlgorithm.NiceHashID == AlgorithmType.Equihash) { if (__ClaymoreZcashStatus.HasTest()) { _currentMiner = MinerFactory.CreateMiner(_currentDevice, _currentAlgorithm); rebenchSame = true; //System.Threading.Thread.Sleep(1000*60*5); __ClaymoreZcashStatus.SetSpeed(_currentAlgorithm.BenchmarkSpeed); __ClaymoreZcashStatus.SetNext(); _currentAlgorithm.ExtraLaunchParameters = __ClaymoreZcashStatus.GetTestExtraParams(); Helpers.ConsolePrint("ClaymoreAMD_Equihash", _currentAlgorithm.ExtraLaunchParameters); _currentMiner.InitBenchmarkSetup(new MiningPair(_currentDevice, _currentAlgorithm)); } if (__ClaymoreZcashStatus.HasTest() == false) { rebenchSame = false; // set fastest mode _currentAlgorithm.BenchmarkSpeed = __ClaymoreZcashStatus.GetFastestTime(); _currentAlgorithm.ExtraLaunchParameters = __ClaymoreZcashStatus.GetFastestExtraParams(); } } if (!rebenchSame) { _benchmarkingTimer.Stop(); } if (!success && !rebenchSame) { // add new failed list _benchmarkFailedAlgoPerDev.Add( new DeviceAlgo() { Device = _currentDevice.Name, Algorithm = _currentAlgorithm.AlgorithmName }); algorithmsListView1.SetSpeedStatus(_currentDevice, _currentAlgorithm, status); } else if (!rebenchSame) { // set status to empty string it will return speed _currentAlgorithm.ClearBenchmarkPending(); algorithmsListView1.SetSpeedStatus(_currentDevice, _currentAlgorithm, ""); } if (rebenchSame) { if (__CPUBenchmarkStatus != null) { _currentMiner.BenchmarkStart(__CPUBenchmarkStatus.Time, this); } else if (__ClaymoreZcashStatus != null) { _currentMiner.BenchmarkStart(__ClaymoreZcashStatus.Time, this); } } else { NextBenchmark(); } }); }
void NextBenchmark() { if (_bechmarkCurrentIndex > -1) { StepUpBenchmarkStepProgress(); } ++_bechmarkCurrentIndex; if (_bechmarkCurrentIndex >= _benchmarkAlgorithmsCount) { EndBenchmark(); return; } Tuple <ComputeDevice, Queue <Algorithm> > currentDeviceAlgosTuple; Queue <Algorithm> algorithmBenchmarkQueue; while (_benchmarkDevicesAlgorithmQueue.Count > 0) { currentDeviceAlgosTuple = _benchmarkDevicesAlgorithmQueue[0]; _currentDevice = currentDeviceAlgosTuple.Item1; algorithmBenchmarkQueue = currentDeviceAlgosTuple.Item2; if (algorithmBenchmarkQueue.Count != 0) { _currentAlgorithm = algorithmBenchmarkQueue.Dequeue(); break; } else { _benchmarkDevicesAlgorithmQueue.RemoveAt(0); } } if (_currentDevice != null && _currentAlgorithm != null) { _currentMiner = MinerFactory.CreateMiner(_currentDevice, _currentAlgorithm); if (_currentAlgorithm.MinerBaseType == MinerBaseType.XmrStackCPU && _currentAlgorithm.NiceHashID == AlgorithmType.CryptoNight && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters) && _currentAlgorithm.ExtraLaunchParameters.Contains("enable_ht=true") == false) { __CPUBenchmarkStatus = new CPUBenchmarkStatus(Globals.ThreadsPerCPU); _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.LessTreads; } else { __CPUBenchmarkStatus = null; } if (_currentAlgorithm.MinerBaseType == MinerBaseType.Claymore && _currentAlgorithm.NiceHashID == AlgorithmType.Equihash && _currentAlgorithm.ExtraLaunchParameters != null && !_currentAlgorithm.ExtraLaunchParameters.Contains("-asm")) { __ClaymoreZcashStatus = new ClaymoreZcashStatus(_currentAlgorithm.ExtraLaunchParameters); _currentAlgorithm.ExtraLaunchParameters = __ClaymoreZcashStatus.GetTestExtraParams(); } else { __ClaymoreZcashStatus = null; } } if (_currentMiner != null && _currentAlgorithm != null) { _benchmarkMiners.Add(_currentMiner); CurrentAlgoName = AlgorithmNiceHashNames.GetName(_currentAlgorithm.NiceHashID); _currentMiner.InitBenchmarkSetup(new MiningPair(_currentDevice, _currentAlgorithm)); var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits .GetBenchamrktime(benchmarkOptions1.PerformanceType, _currentDevice.DeviceGroupType); //currentConfig.TimeLimit = time; if (__CPUBenchmarkStatus != null) { __CPUBenchmarkStatus.Time = time; } if (__ClaymoreZcashStatus != null) { __ClaymoreZcashStatus.Time = time; } // dagger about 4 minutes var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time; dotCount = 0; _benchmarkingTimer.Start(); _currentMiner.BenchmarkStart(time, this); algorithmsListView1.SetSpeedStatus(_currentDevice, _currentAlgorithm, getDotsWaitString()); } else { NextBenchmark(); } }
public void CreateMinerTestFail() { var field = new Field(); MinerFactory.CreateMiner("Not existing Miner", field); }