Beispiel #1
0
 private static void LogMiningNonMiningStatuses(List <MiningDevice> enabledDevices, List <Tuple <ComputeDevice, DeviceMiningStatus> > disabledDevicesStatuses)
 {
     // print statuses
     if (disabledDevicesStatuses.Count > 0)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("");
         stringBuilder.AppendLine("Disabled Devices:");
         foreach (var deviceStatus in disabledDevicesStatuses)
         {
             stringBuilder.AppendLine("\t" + GetDisabledDeviceStatusString(deviceStatus));
         }
         Helpers.ConsolePrint(TAG, stringBuilder.ToString());
     }
     if (enabledDevices.Count > 0)
     {
         // print enabled
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("");
         stringBuilder.AppendLine("Enabled Devices for Mining session:");
         foreach (var miningDevice in enabledDevices)
         {
             var device = miningDevice.Device;
             stringBuilder.AppendLine(String.Format("\tENABLED ({0})", device.GetFullName()));
             foreach (var algo in device.DeviceBenchmarkConfig.AlgorithmSettings.Values)
             {
                 var isEnabled = IsAlgoMiningCapable(algo) && IsValidMinerPath(device, algo);
                 stringBuilder.AppendLine(String.Format("\t\tALGORITHM {0} ({1})",
                                                        isEnabled ? "ENABLED " : "DISABLED", // ENABLED/DISABLED
                                                        AlgorithmNiceHashNames.GetName(algo.NiceHashID)));
             }
         }
         Helpers.ConsolePrint(TAG, stringBuilder.ToString());
     }
 }
Beispiel #2
0
        public void MinerStatsCheck(Dictionary <AlgorithmType, NiceHashSMA> NiceHashData)
        {
            double CurrentProfit = 0.0d;

            _mainFormRatesComunication.ClearRates(_currentAllGroupedDevices.Count);
            foreach (var group in _currentAllGroupedDevices)
            {
                var   groupMiners = _groupedDevicesMiners[CalcGroupedDevicesKey(group)];
                Miner m           = groupMiners.CurrentWorkingMiner;

                // skip if not running
                if (!m.IsRunning)
                {
                    continue;
                }

                APIData AD = m.GetSummary();
                if (AD == null)
                {
                    Helpers.ConsolePrint(m.MinerTAG(), "GetSummary returned null..");
                }
                // set rates
                if (NiceHashData != null && AD != null)
                {
                    m.CurrentRate = NiceHashData[AD.AlgorithmID].paying * AD.Speed * 0.000000001;
                }
                else
                {
                    m.CurrentRate = 0;
                    // set empty
                    AD = new APIData()
                    {
                        AlgorithmID   = m.CurrentAlgorithmType,
                        AlgorithmName = AlgorithmNiceHashNames.GetName(m.CurrentAlgorithmType),
                        Speed         = 0.0d
                    };
                }
                CurrentProfit += m.CurrentRate;
                // Update GUI
                _mainFormRatesComunication.AddRateInfo(m.MinerTAG(), groupMiners.DevicesInfoString, AD, m.CurrentRate, m.IsAPIReadException);
            }
            // check if profitabile
            if (CheckStatus && !IsMiningRegardlesOfProfit)
            {
                CheckStatus = false;
                if (IsProfitable)
                {
                    // check current profit
                    CheckIfShouldMine(CurrentProfit, true);
                }
                else if (!IsProfitable)
                {
                    // recalculate and switch
                    SwichMostProfitableGroupUpMethod(NiceHashData, true);
                }
            }
        }
        public void CalculateProfits(Dictionary <AlgorithmType, double> profits)
        {
            // save last state
            PrevProfitableAlgorithmType = MostProfitableAlgorithmType;
            PrevProfitableMinerBaseType = MostProfitableMinerBaseType;
            // assume none is profitable
            MostProfitableAlgorithmType = AlgorithmType.NONE;
            MostProfitableMinerBaseType = MinerBaseType.NONE;
            // calculate new profits
            foreach (var algo in Algorithms)
            {
                var key          = algo.NiceHashID;
                var secondaryKey = algo.SecondaryNiceHashID;
                if (profits.TryGetValue(key, out var paying))
                {
                    algo.CurNhmSmaDataVal = paying;
                    algo.CurrentProfit    = algo.CurNhmSmaDataVal * algo.AvaragedSpeed * 0.000000001;
                    if (profits.TryGetValue(secondaryKey, out var secPaying))
                    {
                        algo.SecondaryCurNhmSmaDataVal = secPaying;
                        algo.CurrentProfit            +=
                            algo.SecondaryCurNhmSmaDataVal * algo.SecondaryAveragedSpeed * 0.000000001;
                    }
                }
                else
                {
                    algo.CurrentProfit = 0;
                }
            }
            // find max paying value and save key
            double maxProfit = 0;

            foreach (var algo in Algorithms)
            {
                if (maxProfit < algo.CurrentProfit)
                {
                    maxProfit = algo.CurrentProfit;
                    MostProfitableAlgorithmType = algo.DualNiceHashID();
                    MostProfitableMinerBaseType = algo.MinerBaseType;
                }
            }
#if (SWITCH_TESTING)
            var devName = Device.GetFullName();
            // set new most profit
            if (Algorithms.ContainsKey(testingAlgos[next]))
            {
                MostProfitableKey = testingAlgos[next];
            }
            else if (ForceNone)
            {
                MostProfitableKey = AlgorithmType.NONE;
            }
            var mostProfitKeyName = AlgorithmNiceHashNames.GetName(MostProfitableKey);
            Helpers.ConsolePrint("SWITCH_TESTING", String.Format("Setting device {0} to {1}", devName, mostProfitKeyName));
#endif
        }
Beispiel #4
0
        public static void SetNextTest()
        {
            ++next;
            if (next >= testingAlgos.Count)
            {
                next = 0;
            }
            var mostProfitKeyName = AlgorithmNiceHashNames.GetName(testingAlgos[next]);

            Helpers.ConsolePrint("SWITCH_TESTING", String.Format("Setting most MostProfitKey to {0}", mostProfitKeyName));
        }
Beispiel #5
0
        // avarage passed in benchmark values
        public static void AvarageSpeeds(List <MiningDevice> miningDevs)
        {
            // calculate avarage speeds, to ensure mining stability
            // device name, algo key, algos refs list
            Dictionary <string,
                        Dictionary <AlgorithmType,
                                    List <MiningAlgorithm> > > avarager = new Dictionary <string, Dictionary <AlgorithmType, List <MiningAlgorithm> > >();

            // init empty avarager
            foreach (var device in miningDevs)
            {
                string devName = device.Device.Name;
                avarager[devName] = new Dictionary <AlgorithmType, List <MiningAlgorithm> >();
                foreach (var key in AlgorithmNiceHashNames.GetAllAvaliableTypes())
                {
                    avarager[devName][key] = new List <MiningAlgorithm>();
                }
            }
            // fill avarager
            foreach (var device in miningDevs)
            {
                string devName = device.Device.Name;
                foreach (var kvp in device.Algorithms)
                {
                    var             key  = kvp.Key;
                    MiningAlgorithm algo = kvp.Value;
                    avarager[devName][key].Add(algo);
                }
            }
            // calculate avarages
            foreach (var devDict in avarager.Values)
            {
                foreach (List <MiningAlgorithm> miningAlgosList in devDict.Values)
                {
                    // if list not empty calculate avarage
                    if (miningAlgosList.Count > 0)
                    {
                        // calculate avarage
                        double sum = 0;
                        foreach (var algo in miningAlgosList)
                        {
                            sum += algo.AvaragedSpeed;
                        }
                        double avarageSpeed = sum / miningAlgosList.Count;
                        // set avarage
                        foreach (var algo in miningAlgosList)
                        {
                            algo.AvaragedSpeed = avarageSpeed;
                        }
                    }
                }
            }
        }
        public void ShouldReturnNameForValid()
        {
            var expected = new Dictionary <AlgorithmType, string>
            {
                { AlgorithmType.Blake2s, "Blake2s" },
                { AlgorithmType.CryptoNightV8, "CryptoNightV8" }
            };

            foreach (var key in expected.Keys)
            {
                Assert.AreEqual(expected[key], AlgorithmNiceHashNames.GetName(key));
            }
        }
Beispiel #7
0
 public Algorithm(MinerBaseType minerBaseType, AlgorithmType niceHashID, string minerName = "", bool enabled = true)
 {
     NiceHashID            = niceHashID;
     AlgorithmName         = AlgorithmNiceHashNames.GetName(NiceHashID);
     MinerBaseTypeName     = Enum.GetName(typeof(MinerBaseType), minerBaseType);
     AlgorithmStringID     = MinerBaseTypeName + "_" + AlgorithmName;
     MinerBaseType         = minerBaseType;
     MinerName             = minerName;
     ExtraLaunchParameters = "";
     LessThreads           = 0;
     Enabled         = enabled;
     BenchmarkStatus = "";
 }
Beispiel #8
0
        public void CalculateProfits(Dictionary <AlgorithmType, NiceHashSMA> NiceHashData)
        {
            // assume none is profitable
            MostProfitableKey = AlgorithmType.NONE;
            // calculate new profits
            foreach (var miningAlgo in Algorithms)
            {
                AlgorithmType   key  = miningAlgo.Key;
                MiningAlgorithm algo = miningAlgo.Value;
                if (NiceHashData.ContainsKey(key))
                {
                    algo.CurNhmSMADataVal = NiceHashData[key].paying;
                    algo.CurrentProfit    = algo.CurNhmSMADataVal * algo.AvaragedSpeed * 0.000000001;
                }
                else
                {
                    algo.CurrentProfit = 0;
                }
            }
            // find max paying value and save key
            double maxProfit = 0;

            foreach (var miningAlgo in Algorithms)
            {
                AlgorithmType   key  = miningAlgo.Key;
                MiningAlgorithm algo = miningAlgo.Value;
                if (maxProfit < algo.CurrentProfit)
                {
                    maxProfit         = algo.CurrentProfit;
                    MostProfitableKey = key;
                }
            }
#if (SWITCH_TESTING)
            var devName = Device.GetFullName();
            // set new most profit
            if (Algorithms.ContainsKey(testingAlgos[next]))
            {
                MostProfitableKey = testingAlgos[next];
            }
            else if (ForceNone)
            {
                MostProfitableKey = AlgorithmType.NONE;
            }
            var mostProfitKeyName = AlgorithmNiceHashNames.GetName(MostProfitableKey);
            Helpers.ConsolePrint("SWITCH_TESTING", String.Format("Setting device {0} to {1}", devName, mostProfitKeyName));
#endif
        }
        public Algorithm(MinerBaseType minerBaseType, AlgorithmType niceHashID, string minerName)
        {
            NiceHashID = niceHashID;

            AlgorithmName     = AlgorithmNiceHashNames.GetName(NiceHashID);
            MinerBaseTypeName = Enum.GetName(typeof(MinerBaseType), minerBaseType);
            AlgorithmStringID = MinerBaseTypeName + "_" + AlgorithmName;

            MinerBaseType = minerBaseType;
            MinerName     = minerName;

            ExtraLaunchParameters = "";
            LessThreads           = 0;
            Enabled = !(NiceHashID == AlgorithmType.Nist5 ||
                        (NiceHashID == AlgorithmType.NeoScrypt && minerBaseType == MinerBaseType.sgminer));
            BenchmarkStatus = "";
        }
Beispiel #10
0
        public void CalculateProfits(Dictionary <AlgorithmType, double> profits)
        {
            // save last state
            PrevProfitableAlgorithmType = MostProfitableAlgorithmType;
            PrevProfitableMinerBaseType = MostProfitableMinerBaseType;
            // assume none is profitable
            MostProfitableAlgorithmType = AlgorithmType.NONE;
            MostProfitableMinerBaseType = MinerBaseType.NONE;
            // calculate new profits
            foreach (var algo in Algorithms)
            {
                algo.UpdateCurProfit(profits);
            }

            // find max paying value and save key
            double maxProfit = 0;

            foreach (var algo in Algorithms)
            {
                if (maxProfit < algo.CurrentProfit)
                {
                    maxProfit = algo.CurrentProfit;
                    MostProfitableAlgorithmType = algo.DualNiceHashID;
                    MostProfitableMinerBaseType = algo.MinerBaseType;
                }
            }
#if (SWITCH_TESTING)
            var devName = Device.GetFullName();
            // set new most profit
            if (Algorithms.ContainsKey(testingAlgos[next]))
            {
                MostProfitableKey = testingAlgos[next];
            }
            else if (ForceNone)
            {
                MostProfitableKey = AlgorithmType.NONE;
            }
            var mostProfitKeyName = AlgorithmNiceHashNames.GetName(MostProfitableKey);
            Helpers.ConsolePrint("SWITCH_TESTING", String.Format("Setting device {0} to {1}", devName, mostProfitKeyName));
#endif
        }
Beispiel #11
0
        public void MinerStatsCheck(Dictionary <AlgorithmType, NiceHashSMA> NiceHashData)
        {
            _mainFormRatesComunication.ClearRates(_currentAllGroupedDevices.Count);
            foreach (var group in _currentAllGroupedDevices)
            {
                var   groupMiners = _groupedDevicesMiners[CalcGroupedDevicesKey(group)];
                Miner m           = groupMiners.CurrentWorkingMiner;

                // skip if not running
                if (!m.IsRunning)
                {
                    continue;
                }

                APIData AD = m.GetSummary();
                if (AD == null)
                {
                    Helpers.ConsolePrint(m.MinerTAG(), "GetSummary returned null..");
                }
                // set rates
                if (NiceHashData != null && AD != null)
                {
                    m.CurrentRate = NiceHashData[AD.AlgorithmID].paying * AD.Speed * 0.000000001;
                }
                else
                {
                    m.CurrentRate = 0;
                    // set empty
                    AD = new APIData()
                    {
                        AlgorithmID   = m.CurrentAlgorithmType,
                        AlgorithmName = AlgorithmNiceHashNames.GetName(m.CurrentAlgorithmType),
                        Speed         = 0.0d
                    };
                }

                // Update GUI
                _mainFormRatesComunication.AddRateInfo(m.MinerTAG(), groupMiners.DevicesInfoString, AD, m.CurrentRate, m.IsAPIReadException);
            }
        }
Beispiel #12
0
        public Algorithm(MinerBaseType minerBaseType, AlgorithmType niceHashID, string minerName)
        {
            NiceHashID = niceHashID;

            AlgorithmName     = AlgorithmNiceHashNames.GetName(NiceHashID);
            MinerBaseTypeName = Enum.GetName(typeof(MinerBaseType), minerBaseType);
            AlgorithmStringID = MinerBaseTypeName + "_" + AlgorithmName;

            MinerBaseType = minerBaseType;
            MinerName     = minerName;

            ExtraLaunchParameters = "";
            LessThreads           = 0;
            Enabled = !(NiceHashID == AlgorithmType.Nist5 ||
                        (NiceHashID == AlgorithmType.NeoScrypt && minerBaseType == MinerBaseType.sgminer));
            Enabled         = !(NiceHashID == AlgorithmType.CryptoNightV7) && minerBaseType == MinerBaseType.XmrigAMD;
            Enabled         = !(NiceHashID == AlgorithmType.CryptoNightV8) && minerBaseType == MinerBaseType.XmrigAMD;
            Enabled         = !(NiceHashID == AlgorithmType.CryptoNightV8) && minerBaseType == MinerBaseType.SRBMiner;
            Enabled         = !(NiceHashID == AlgorithmType.CryptoNightHeavy) && minerBaseType == MinerBaseType.SRBMiner;
            Enabled         = !(NiceHashID == AlgorithmType.Lyra2REv2) && minerBaseType == MinerBaseType.mkxminer;
            BenchmarkStatus = "";
        }
Beispiel #13
0
            public void SetNext(ref PerDeviceProifitDictionary devProfits, List <ComputeDevice> enabledDevices)
            {
                foreach (var cDev in enabledDevices)
                {
                    var devUUID           = cDev.UUID;
                    var curStepCheckIndex = _curStepCheck[devUUID];
                    var _mostProfitKey    = _allAvaliableAlgoKeys[devUUID][curStepCheckIndex];
                    var mostProfitKeyName = AlgorithmNiceHashNames.GetName(_mostProfitKey);
                    Helpers.ConsolePrint(TAG, String.Format("Setting most MostProfitKey to {0}", mostProfitKeyName));

                    // set new most profit
                    Helpers.ConsolePrint(TAG, String.Format("Setting device {0} to {1}", devUUID, mostProfitKeyName));
                    devProfits[devUUID][_mostProfitKey] = MOST_PROFIT_REPLACE_VAL;

                    ++curStepCheckIndex;
                    if (curStepCheckIndex >= _allAvaliableAlgoKeys[devUUID].Count)
                    {
                        curStepCheckIndex = 0;
                    }
                    _curStepCheck[devUUID] = curStepCheckIndex;
                }
            }
Beispiel #14
0
        private void NextBenchmark()
        {
            if (_bechmarkCurrentIndex > -1)
            {
                StepUpBenchmarkStepProgress();
            }
            ++_bechmarkCurrentIndex;
            if (_bechmarkCurrentIndex >= _benchmarkAlgorithmsCount)
            {
                EndBenchmark();
                return;
            }

            while (_benchmarkDevicesAlgorithmQueue.Count > 0)
            {
                var currentDeviceAlgosTuple = _benchmarkDevicesAlgorithmQueue[0];
                _currentDevice = currentDeviceAlgosTuple.Item1;
                var algorithmBenchmarkQueue = currentDeviceAlgosTuple.Item2;
                if (algorithmBenchmarkQueue.Count != 0)
                {
                    _currentAlgorithm = algorithmBenchmarkQueue.Dequeue();
                    break;
                }
                _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));

                if (_currentDevice != null)
                {
                    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();
            }
        }
Beispiel #15
0
        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 = MinersManager.CreateMiner(_currentDevice, _currentAlgorithm);
                if (_currentDevice.DeviceType == DeviceType.CPU && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters))
                {
                    __CPUBenchmarkStatus          = new CPUBenchmarkStatus();
                    _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.LessTreads;
                }
                else
                {
                    __CPUBenchmarkStatus = 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;
                }

                // 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.NiceHashID,
                                                   getDotsWaitString());
            }
            else
            {
                NextBenchmark();
            }
        }
Beispiel #16
0
        public MiningSession(List <ComputeDevice> devices,
                             IMainFormRatesComunication mainFormRatesComunication,
                             string miningLocation, string worker, string btcAdress)
        {
            // init fixed
            _mainFormRatesComunication = mainFormRatesComunication;
            _miningLocation            = miningLocation;

            if (worker.Length > 0)
            {
                _workerBtcStringWorker = btcAdress + "." + worker;
            }
            else
            {
                _workerBtcStringWorker = btcAdress;
            }

            // initial settup
            {
                // used for logging
                List <Tuple <ComputeDevice, DeviceMiningStatus> > disabledDevicesStatuses = new List <Tuple <ComputeDevice, DeviceMiningStatus> >();
                // logging and settup
                List <ComputeDevice> enabledDevices = new List <ComputeDevice>();
                // get enabled devices
                {
                    // check passed devices statuses
                    List <Tuple <ComputeDevice, DeviceMiningStatus> > devicesStatuses = new List <Tuple <ComputeDevice, DeviceMiningStatus> >();
                    foreach (var device in devices)
                    {
                        devicesStatuses.Add(getDeviceMiningStatus(device));
                    }
                    // sort device statuses
                    foreach (var deviceStatus in devicesStatuses)
                    {
                        if (deviceStatus.Item2 == DeviceMiningStatus.CanMine)
                        {
                            enabledDevices.Add(deviceStatus.Item1);
                        }
                        else
                        {
                            disabledDevicesStatuses.Add(deviceStatus);
                        }
                    }
                }
                // print statuses
                if (disabledDevicesStatuses.Count > 0)
                {
                    Helpers.ConsolePrint(TAG, "Disabled Devices:");
                    foreach (var deviceStatus in disabledDevicesStatuses)
                    {
                        ComputeDevice      device = deviceStatus.Item1;
                        DeviceMiningStatus status = deviceStatus.Item2;
                        if (status == DeviceMiningStatus.DeviceNull)
                        {
                            Helpers.ConsolePrint(TAG, "Critical Device is NULL");
                        }
                        else if (status == DeviceMiningStatus.Disabled)
                        {
                            Helpers.ConsolePrint(TAG, String.Format("DISABLED ({0})", device.GetFullName()));
                        }
                        else if (status == DeviceMiningStatus.NoEnabledAlgorithms)
                        {
                            Helpers.ConsolePrint(TAG, String.Format("No Enabled Algorithms ({0})", device.GetFullName()));
                        }
                    }
                }
                if (enabledDevices.Count > 0)
                {
                    // print enabled
                    Helpers.ConsolePrint(TAG, "Enabled Devices for Mining session:");
                    foreach (var device in enabledDevices)
                    {
                        Helpers.ConsolePrint(TAG, String.Format("ENABLED ({0})", device.GetFullName()));
                        foreach (var algo in device.DeviceBenchmarkConfig.AlgorithmSettings.Values)
                        {
                            var isEnabled = IsAlgoMiningCapable(algo);
                            Helpers.ConsolePrint(TAG, String.Format("\t\tALGORITHM {0} ({1})",
                                                                    isEnabled ? "ENABLED " : "DISABLED", // ENABLED/DISABLED
                                                                    AlgorithmNiceHashNames.GetName(algo.NiceHashID)));
                        }
                    }
                    // settup mining devices
                    foreach (var device in enabledDevices)
                    {
                        _miningDevices.Add(new MiningDevice(device));
                    }
                }
            }
            if (_miningDevices.Count > 0)
            {
                // calculate avarage speeds, to ensure mining stability
                // device name, algo key, algos refs list
                Dictionary <string,
                            Dictionary <AlgorithmType,
                                        List <MiningAlgorithm> > > avarager = new Dictionary <string, Dictionary <AlgorithmType, List <MiningAlgorithm> > >();
                // init empty avarager
                foreach (var device in _miningDevices)
                {
                    string devName = device.Device.Name;
                    avarager[devName] = new Dictionary <AlgorithmType, List <MiningAlgorithm> >();
                    foreach (var key in AlgorithmNiceHashNames.GetAllAvaliableTypes())
                    {
                        avarager[devName][key] = new List <MiningAlgorithm>();
                    }
                }
                // fill avarager
                foreach (var device in _miningDevices)
                {
                    string devName = device.Device.Name;
                    foreach (var kvp in device.Algorithms)
                    {
                        var             key  = kvp.Key;
                        MiningAlgorithm algo = kvp.Value;
                        avarager[devName][key].Add(algo);
                    }
                }
                // calculate avarages
                foreach (var devDict in avarager.Values)
                {
                    foreach (List <MiningAlgorithm> miningAlgosList in devDict.Values)
                    {
                        // if list not empty calculate avarage
                        if (miningAlgosList.Count > 0)
                        {
                            // calculate avarage
                            double sum = 0;
                            foreach (var algo in miningAlgosList)
                            {
                                sum += algo.AvaragedSpeed;
                            }
                            double avarageSpeed = sum / miningAlgosList.Count;
                            // set avarage
                            foreach (var algo in miningAlgosList)
                            {
                                algo.AvaragedSpeed = avarageSpeed;
                            }
                        }
                    }
                }
            }

            // init timer stuff
            _preventSleepTimer          = new Timer();
            _preventSleepTimer.Elapsed += PreventSleepTimer_Tick;
            // sleep time is minimal 1 minute
            _preventSleepTimer.Interval = 20 * 1000; // leave this interval, it works

            // set internet checking
            _internetCheckTimer          = new Timer();
            _internetCheckTimer.Elapsed += InternetCheckTimer_Tick;
            _internetCheckTimer.Interval = 1000 * 30 * 1; // every minute or 5?? // 1000 * 60 * 1

            _miningStatusCheckTimer          = new Timer();
            _miningStatusCheckTimer.Elapsed += MiningStatusCheckTimer_Tick;
            _miningStatusCheckTimer.Interval = 1000 * 30;

            // assume profitable
            IsProfitable = true;
            // assume we have internet
            IsConnectedToInternet = true;

            if (IsMiningEnabled)
            {
                _preventSleepTimer.Start();
                _internetCheckTimer.Start();
                _miningStatusCheckTimer.Start();
            }

            IsMiningRegardlesOfProfit = ConfigManager.Instance.GeneralConfig.MinimumProfit == 0;
        }
        public void ShouldReturnNotFoundForInvalid()
        {
            var x = AlgorithmNiceHashNames.GetName((AlgorithmType)100);

            Assert.AreEqual("NameNotFound type not supported", x);
        }
Beispiel #18
0
        public void SwichMostProfitableGroupUpMethod(Dictionary <AlgorithmType, NiceHashSMA> NiceHashData, bool log = true)
        {
#if (SWITCH_TESTING)
            MiningDevice.SetNextTest();
#endif
            List <MiningPair> profitableDevices = new List <MiningPair>();
            double            CurrentProfit     = 0.0d;
            foreach (var device in _miningDevices)
            {
                // calculate profits
                device.CalculateProfits(NiceHashData);
                // check if device has profitable algo
                if (device.HasProfitableAlgo())
                {
                    profitableDevices.Add(device.GetMostProfitablePair());
                    CurrentProfit += device.GetCurrentMostProfitValue;
                }
            }
            // print profit statuses
            if (log)
            {
                StringBuilder stringBuilderFull = new StringBuilder();
                stringBuilderFull.AppendLine("Current device profits:");
                foreach (var device in _miningDevices)
                {
                    StringBuilder stringBuilderDevice = new StringBuilder();
                    stringBuilderDevice.AppendLine(String.Format("\tProfits for {0} ({1}):", device.Device.UUID, device.Device.Name));
                    foreach (var algo in device.Algorithms)
                    {
                        stringBuilderDevice.AppendLine(String.Format("\t\tPROFIT = {0}\t(SPEED = {1}\t\t| NHSMA = {2})\t[{3}]",
                                                                     algo.Value.CurrentProfit.ToString(DOUBLE_FORMAT), // Profit
                                                                     algo.Value.AvaragedSpeed,                         // Speed
                                                                     algo.Value.CurNhmSMADataVal,                      // NiceHashData
                                                                     AlgorithmNiceHashNames.GetName(algo.Key)          // Name
                                                                     ));
                    }
                    // most profitable
                    stringBuilderDevice.AppendLine(String.Format("\t\tMOST PROFITABLE ALGO: {0}, PROFIT: {1}",
                                                                 AlgorithmNiceHashNames.GetName(device.MostProfitableKey),
                                                                 device.GetCurrentMostProfitValue.ToString(DOUBLE_FORMAT)));
                    stringBuilderFull.AppendLine(stringBuilderDevice.ToString());
                }
                Helpers.ConsolePrint(TAG, stringBuilderFull.ToString());
            }

            // check if should mine
            if (CheckIfShouldMine(CurrentProfit, log) == false)
            {
                return;
            }

            Dictionary <string, List <MiningPair> > newGroupedMiningPairs = new Dictionary <string, List <MiningPair> >();
            // group devices with same supported algorithms
            {
                var currentGroupedDevices = new List <GroupedDevices>();
                for (int first = 0; first < profitableDevices.Count; ++first)
                {
                    var firstDev = profitableDevices[first].Device;
                    // check if is in group
                    bool isInGroup = false;
                    foreach (var groupedDevices in currentGroupedDevices)
                    {
                        if (groupedDevices.Contains(firstDev.UUID))
                        {
                            isInGroup = true;
                            break;
                        }
                    }
                    // if device is not in any group create new group and check if other device should group
                    if (isInGroup == false)
                    {
                        var newGroup    = new GroupedDevices();
                        var miningPairs = new List <MiningPair>()
                        {
                            profitableDevices[first]
                        };
                        newGroup.Add(firstDev.UUID);
                        for (int second = first + 1; second < profitableDevices.Count; ++second)
                        {
                            // check if we should group
                            var firstPair  = profitableDevices[first];
                            var secondPair = profitableDevices[second];
                            if (GroupingLogic.ShouldGroup(firstPair, secondPair))
                            {
                                var secondDev = profitableDevices[second].Device;
                                newGroup.Add(secondDev.UUID);
                                miningPairs.Add(profitableDevices[second]);
                            }
                        }
                        currentGroupedDevices.Add(newGroup);
                        newGroupedMiningPairs[CalcGroupedDevicesKey(newGroup)] = miningPairs;
                    }
                }
            }
            //bool IsMinerStatsCheckUpdate = false;
            {
                // check which groupMiners should be stopped and which ones should be started and which to keep running
                Dictionary <string, GroupMiner> toStopGroupMiners   = new Dictionary <string, GroupMiner>();
                Dictionary <string, GroupMiner> toRunNewGroupMiners = new Dictionary <string, GroupMiner>();
                // check what to stop/update
                foreach (string runningGroupKey in _runningGroupMiners.Keys)
                {
                    if (newGroupedMiningPairs.ContainsKey(runningGroupKey) == false)
                    {
                        // runningGroupKey not in new group definately needs to be stopped and removed from curently running
                        toStopGroupMiners[runningGroupKey] = _runningGroupMiners[runningGroupKey];
                    }
                    else
                    {
                        // runningGroupKey is contained but needs to check if mining algorithm is changed
                        var miningPairs = newGroupedMiningPairs[runningGroupKey];
                        var newAlgoType = GetMinerPairAlgorithmType(miningPairs);
                        if (newAlgoType != AlgorithmType.NONE && newAlgoType != AlgorithmType.INVALID)
                        {
                            // if algoType valid and different from currently running update
                            if (newAlgoType != _runningGroupMiners[runningGroupKey].AlgorithmType)
                            {
                                // remove current one and schedule to stop mining
                                toStopGroupMiners[runningGroupKey] = _runningGroupMiners[runningGroupKey];
                                // create new one TODO check if DaggerHashimoto
                                GroupMiner newGroupMiner = null;
                                if (newAlgoType == AlgorithmType.DaggerHashimoto)
                                {
                                    if (_ethminerNVIDIAPaused != null && _ethminerNVIDIAPaused.Key == runningGroupKey)
                                    {
                                        newGroupMiner = _ethminerNVIDIAPaused;
                                    }
                                    if (_ethminerAMDPaused != null && _ethminerAMDPaused.Key == runningGroupKey)
                                    {
                                        newGroupMiner = _ethminerAMDPaused;
                                    }
                                }
                                if (newGroupMiner == null)
                                {
                                    newGroupMiner = new GroupMiner(miningPairs, runningGroupKey);
                                }
                                toRunNewGroupMiners[runningGroupKey] = newGroupMiner;
                            }
                        }
                    }
                }
                // check brand new
                foreach (var kvp in newGroupedMiningPairs)
                {
                    var key         = kvp.Key;
                    var miningPairs = kvp.Value;
                    if (_runningGroupMiners.ContainsKey(key) == false)
                    {
                        GroupMiner newGroupMiner = new GroupMiner(miningPairs, key);
                        toRunNewGroupMiners[key] = newGroupMiner;
                    }
                }
                // stop old miners
                foreach (var toStop in toStopGroupMiners.Values)
                {
                    toStop.Stop();
                    _runningGroupMiners.Remove(toStop.Key);
                    // TODO check if daggerHashimoto and save
                    if (toStop.AlgorithmType == AlgorithmType.DaggerHashimoto)
                    {
                        if (toStop.DeviceType == DeviceType.NVIDIA)
                        {
                            _ethminerNVIDIAPaused = toStop;
                        }
                        else if (toStop.DeviceType == DeviceType.AMD)
                        {
                            _ethminerAMDPaused = toStop;
                        }
                    }
                }
                // start new miners
                foreach (var toStart in toRunNewGroupMiners.Values)
                {
                    toStart.Start(_miningLocation, _btcAdress, _worker);
                    _runningGroupMiners[toStart.Key] = toStart;
                }
            }

            // stats quick fix code
            //if (_currentAllGroupedDevices.Count != _previousAllGroupedDevices.Count) {
            MinerStatsCheck(NiceHashData);
            //}
        }
Beispiel #19
0
        public void SwichMostProfitableGroupUpMethod(Dictionary <AlgorithmType, NiceHashSMA> NiceHashData, bool log = true)
        {
            List <MiningDevice> profitableDevices = new List <MiningDevice>();
            double CurrentProfit = 0.0d;

            foreach (var device in _miningDevices)
            {
                // calculate profits
                device.CalculateProfits(NiceHashData);
                // check if device has profitable algo
                if (device.MostProfitableKey != AlgorithmType.NONE)
                {
                    profitableDevices.Add(device);
                    CurrentProfit += device.GetCurrentMostProfitValue;
                    device.Device.MostProfitableAlgorithm = device.Algorithms[device.MostProfitableKey].algoRef;
                }
            }
            // print profit statuses
            if (log)
            {
                StringBuilder stringBuilderFull = new StringBuilder();
                stringBuilderFull.AppendLine("Current device profits:");
                foreach (var device in _miningDevices)
                {
                    StringBuilder stringBuilderDevice = new StringBuilder();
                    stringBuilderDevice.AppendLine(String.Format("\tProfits for {0} ({1}):", device.Device.UUID, device.Device.Name));
                    foreach (var algo in device.Algorithms)
                    {
                        stringBuilderDevice.AppendLine(String.Format("\t\tPROFIT = {0}\t(SPEED = {1}\t\t| NHSMA = {2})\t[{3}]",
                                                                     algo.Value.CurrentProfit.ToString(DOUBLE_FORMAT), // Profit
                                                                     algo.Value.AvaragedSpeed,                         // Speed
                                                                     algo.Value.CurNhmSMADataVal,                      // NiceHashData
                                                                     AlgorithmNiceHashNames.GetName(algo.Key)          // Name
                                                                     ));
                    }
                    // most profitable
                    stringBuilderDevice.AppendLine(String.Format("\t\tMOST PROFITABLE ALGO: {0}, PROFIT: {1}",
                                                                 AlgorithmNiceHashNames.GetName(device.MostProfitableKey),
                                                                 device.GetCurrentMostProfitValue.ToString(DOUBLE_FORMAT)));
                    stringBuilderFull.AppendLine(stringBuilderDevice.ToString());
                }
                Helpers.ConsolePrint(TAG, stringBuilderFull.ToString());
            }

            // check if should mine
            if (CheckIfShouldMine(CurrentProfit, log) == false)
            {
                return;
            }

            // group devices with same supported algorithms
            _previousAllGroupedDevices = _currentAllGroupedDevices;
            _currentAllGroupedDevices  = new List <SortedSet <string> >();
            Dictionary <GroupedDevices, Algorithm> newGroupAndAlgorithm = new Dictionary <GroupedDevices, Algorithm>();

            for (int first = 0; first < profitableDevices.Count; ++first)
            {
                var firstDev = profitableDevices[first].Device;
                // skip if no algorithm is profitable
                if (firstDev.MostProfitableAlgorithm == null)
                {
                    if (log)
                    {
                        Helpers.ConsolePrint("SwichMostProfitableGroupUpMethod", String.Format("Device {0}, MostProfitableAlgorithm == null", firstDev.Name));
                    }
                    continue;
                }
                // check if is in group
                bool isInGroup = false;
                foreach (var groupedDevices in _currentAllGroupedDevices)
                {
                    if (groupedDevices.Contains(firstDev.UUID))
                    {
                        isInGroup = true;
                        break;
                    }
                }
                if (isInGroup)
                {
                    continue;
                }

                var newGroup = new GroupedDevices();
                newGroup.Add(firstDev.UUID);
                for (int second = first + 1; second < profitableDevices.Count; ++second)
                {
                    var secondDev = profitableDevices[second].Device;
                    // first check if second device has profitable algorithm
                    if (secondDev.MostProfitableAlgorithm != null)
                    {
                        // check if we should group
                        if (GroupingLogic.IsEquihashGroupLogic(firstDev, secondDev) ||
                            GroupingLogic.IsDaggerAndSameComputePlatform(firstDev, secondDev) ||
                            GroupingLogic.IsGroupBinaryAndAlgorithmSame(firstDev, secondDev))
                        {
                            newGroup.Add(secondDev.UUID);
                        }
                    }
                }

                _currentAllGroupedDevices.Add(newGroup);
                newGroupAndAlgorithm.Add(newGroup, firstDev.MostProfitableAlgorithm);
            }

            // stop groupes that aren't in current group devices
            foreach (var curPrevGroup in _previousAllGroupedDevices)
            {
                var  curPrevGroupKey = CalcGroupedDevicesKey(curPrevGroup);
                bool contains        = false;
                foreach (var curCheckGroup in _currentAllGroupedDevices)
                {
                    var curCheckGroupKey = CalcGroupedDevicesKey(curCheckGroup);
                    if (curPrevGroupKey == curCheckGroupKey)
                    {
                        contains = true;
                        break;
                    }
                }
                if (!contains)
                {
                    _groupedDevicesMiners[curPrevGroupKey].Stop();
                }
            }
            // switch to newGroupAndAlgorithm most profitable algorithm
            foreach (var kvpGroupAlgorithm in newGroupAndAlgorithm)
            {
                var group     = kvpGroupAlgorithm.Key;
                var algorithm = kvpGroupAlgorithm.Value;

                GroupMiners currentGroupMiners;
                // try find if it doesn't exist create new
                string groupStringKey = CalcGroupedDevicesKey(group);
                if (!_groupedDevicesMiners.TryGetValue(groupStringKey, out currentGroupMiners))
                {
                    currentGroupMiners = new GroupMiners(group);
                    _groupedDevicesMiners.Add(groupStringKey, currentGroupMiners);
                }
                currentGroupMiners.StartAlgorihtm(algorithm, _miningLocation, _workerBtcStringWorker);
            }

            // stats quick fix code
            if (_currentAllGroupedDevices.Count != _previousAllGroupedDevices.Count)
            {
                MinerStatsCheck(NiceHashData);
            }
        }
Beispiel #20
0
        PerDeviceProifitDictionary GetEnabledDeviceProifitDictionary(PerDeviceSpeedDictionary speedDict, Dictionary <AlgorithmType, NiceHashSMA> NiceHashData)
        {
            PerDeviceProifitDictionary profitDict = new PerDeviceProifitDictionary();

            // log stuff
            int           MAX_NAME_LEN      = "daggerhashimoto".Length;
            int           MAX_SPEED_LEN     = 15;
            StringBuilder stringBuilderFull = new StringBuilder();

            stringBuilderFull.AppendLine("Current device profits:");

            foreach (var nameBenchKvp in speedDict)
            {
                var           deviceUUID          = nameBenchKvp.Key;
                var           curDevProfits       = new Dictionary <AlgorithmType, double>();
                StringBuilder stringBuilderDevice = new StringBuilder();
                stringBuilderDevice.AppendLine(String.Format("\tProfits for {0} ({1}):", deviceUUID, ComputeDevice.GetNameForUUID(deviceUUID)));
                AlgorithmType mostProfitKey     = AlgorithmType.NONE;
                double        mostProfitAlgoVal = -1;
                foreach (var algoSpeedKvp in nameBenchKvp.Value)
                {
                    // Log stuff and calculation
                    string name            = AlgorithmNiceHashNames.GetName(algoSpeedKvp.Key);
                    int    namePreatyCount = MAX_NAME_LEN - name.Length;
                    if (namePreatyCount <= 0)
                    {
                        namePreatyCount = 1;
                    }
                    string namePreaty    = name + new String(' ', namePreatyCount);
                    bool   isEnabled     = algoSpeedKvp.Value > 0;
                    double nhmSMADataVal = NiceHashData[algoSpeedKvp.Key].paying;
                    // TODO what is the constant at the end?
                    double algoProfit = algoSpeedKvp.Value * nhmSMADataVal * 0.000000001;

                    // calculate
                    if (isEnabled)
                    {
                        curDevProfits.Add(algoSpeedKvp.Key, algoProfit);
                        if (mostProfitAlgoVal < algoProfit)
                        {
                            mostProfitKey     = algoSpeedKvp.Key;
                            mostProfitAlgoVal = algoProfit;
                        }
                    }
                    else
                    {
                        // if disabled make unprofitable
                        curDevProfits.Add(algoSpeedKvp.Key, -1000000);
                        algoProfit *= -1; // make bigger then 0 for logging reasons
                    }
                    // log stuff
                    string speedStr      = algoSpeedKvp.Value.ToString("F3");
                    int    speedStrCount = MAX_SPEED_LEN - speedStr.Length;
                    if (speedStrCount <= 0)
                    {
                        speedStrCount = 1;
                    }
                    string speedPreaty = new String(' ', speedStrCount) + speedStr;
                    stringBuilderDevice.AppendLine(String.Format("\t\t{0}\t:\tPROFIT = {1}  ({2}, SPEED = {3}, NHSMA = {4})",
                                                                 namePreaty,                           // Name
                                                                 algoProfit.ToString(DOUBLE_FORMAT),   // Profit
                                                                 isEnabled ? "ENABLED " : "DISABLED",  // ENABLED/DISABLED
                                                                 speedPreaty,                          // Speed
                                                                 nhmSMADataVal.ToString(DOUBLE_FORMAT) // NiceHashData
                                                                 ));
                }
                // add profits
                profitDict.Add(deviceUUID, curDevProfits);
                // log stuff
                stringBuilderDevice.AppendLine(String.Format("\t\tMOST PROFITABLE (ENABLED) ALGO: {0}, PROFIT: {1}",
                                                             AlgorithmNiceHashNames.GetName(mostProfitKey),
                                                             mostProfitAlgoVal.ToString(DOUBLE_FORMAT)));
                stringBuilderFull.AppendLine(stringBuilderDevice.ToString());
            }

            Helpers.ConsolePrint(TAG, stringBuilderFull.ToString());
            return(profitDict);
        }
        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);
                }
            }

            var currentConfig = _currentDevice.DeviceBenchmarkConfig;

            if (_currentDevice.DeviceGroupType == DeviceGroupType.CPU)
            {
                _currentMiner = MinersManager.GetCpuMiner(_currentDevice.Group);
            }
            else
            {
                _currentMiner = MinersManager.CreateMiner(currentConfig.DeviceGroupType, _currentAlgorithm.NiceHashID);
            }

            if (_currentMiner != null && _currentAlgorithm != null)
            {
                _benchmarkMiners.Add(_currentMiner);
                CurrentAlgoName = AlgorithmNiceHashNames.GetName(_currentAlgorithm.NiceHashID);
                // this has no effect for CPU miners
                _currentMiner.SetCDevs(new string[] { _currentDevice.UUID });

                var time = ConfigManager.Instance.GeneralConfig.BenchmarkTimeLimits
                           .GetBenchamrktime(benchmarkOptions1.PerformanceType, _currentDevice.DeviceGroupType);
                //currentConfig.TimeLimit = time;

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

                dotCount = 0;
                _benchmarkingTimer.Start();

                _currentMiner.BenchmarkStart(_currentDevice, _currentAlgorithm, time, this);
                algorithmsListView1.SetSpeedStatus(_currentDevice, _currentAlgorithm.NiceHashID,
                                                   getDotsWaitString());
            }
            else
            {
                NextBenchmark();
            }
        }
Beispiel #22
0
        void NextBenchmark()
        {
            ++_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.ClaymoreAMD && _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(BenchmarkPerformanceType.Quick, _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);
            }
            else
            {
                NextBenchmark();
            }
        }