コード例 #1
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;
                        }
                    }
                }
            }
        }
コード例 #2
0
 public MiningDevice(ComputeDevice device)
 {
     Device = device;
     foreach (var kvp in Device.AlgorithmSettings) {
         AlgorithmType key = kvp.Key;
         Algorithm algo = kvp.Value;
         bool isAlgoMiningCapable = GroupSetupUtils.IsAlgoMiningCapable(algo);
         bool isValidMinerPath = GroupSetupUtils.IsValidMinerPath(device, algo);
         if (isAlgoMiningCapable && isValidMinerPath) {
             Algorithms[key] = new MiningAlgorithm(device, algo);
         }
     }
 }
コード例 #3
0
 public MiningDevice(ComputeDevice device)
 {
     Device = device;
     foreach (var kvp in Device.AlgorithmSettings)
     {
         AlgorithmType key  = kvp.Key;
         Algorithm     algo = kvp.Value;
         bool          isAlgoMiningCapable = GroupSetupUtils.IsAlgoMiningCapable(algo);
         bool          isValidMinerPath    = GroupSetupUtils.IsValidMinerPath(device, algo);
         if (isAlgoMiningCapable && isValidMinerPath)
         {
             Algorithms[key] = new MiningAlgorithm(device, algo);
         }
     }
 }
コード例 #4
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
        }