// , 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)); } }
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(); }
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 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(); } }
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); }
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, ""); } } }