Esempio n. 1
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);
        }
Esempio n. 2
0
        public bool StartInitialize(IMainFormRatesComunication mainFormRatesComunication,
                                    string miningLocation, string worker, string btcAdress)
        {
            _mainFormRatesComunication = mainFormRatesComunication;
            _miningLocation            = miningLocation;
            _worker    = worker;
            _btcAdress = btcAdress;

            if (_worker.Length > 0)
            {
                _workerBtcStringWorker = _btcAdress + "." + _worker;
            }
            else
            {
                _workerBtcStringWorker = _btcAdress;
            }

            _perDeviceSpeedDictionary = GetEnabledDeviceTypeSpeeds();
            //_groupedDevicesMiners = new Dictionary<GroupedDevices, GroupMiners>();
            _groupedDevicesMiners     = new Dictionary <string, GroupMiners>();
            _enabledDevices           = new List <ComputeDevice>();
            _currentAllGroupedDevices = new AllGroupedDevices();

            // assume profitable
            IsProfitable = true;


            // this checks if there are enabled devices and enabled algorithms
            bool isMiningEnabled = false;

            foreach (var cdev in ComputeDevice.AllAvaliableDevices)
            {
                if (cdev.Enabled)
                {
                    _enabledDevices.Add(cdev);
                    // check if in CPU group and add the saved CPU miners
                    if (cdev.DeviceGroupType == DeviceGroupType.CPU)
                    {
                        GroupedDevices gdevs = new GroupedDevices();
                        gdevs.Add(cdev.UUID);
                        cpuminer      miner         = _cpuMiners[cdev.Group];
                        CpuGroupMiner cpuGroupMiner = new CpuGroupMiner(gdevs, miner);
                        _groupedDevicesMiners.Add(CalcGroupedDevicesKey(gdevs), cpuGroupMiner);
                    }
                    // check if any algorithm enabled
                    if (!isMiningEnabled)
                    {
                        foreach (var algorithm in cdev.DeviceBenchmarkConfig.AlgorithmSettings)
                        {
                            if (!algorithm.Value.Skip)
                            {
                                isMiningEnabled = true;
                                break;
                            }
                        }
                    }
                }
            }

            if (isMiningEnabled)
            {
                _preventSleepTimer.Start();
            }

            IsCurrentlyIdle = !isMiningEnabled;

            return(isMiningEnabled);
        }
Esempio n. 3
0
        /// <summary>
        /// GetEnabledDeviceTypeBenchmarks calculates currently enabled ComputeDevice benchmark speeds.
        /// If there are more cards of the same model it multiplies the speeds by it's count
        /// </summary>
        /// <returns></returns>
        PerDeviceSpeedDictionary GetEnabledDeviceTypeSpeeds()
        {
            PerDeviceSpeedDictionary perDeviceTypeBenchmarks = new PerDeviceSpeedDictionary();

            // init algorithms count 0
            foreach (var curCDev in ComputeDevice.AllAvaliableDevices)
            {
                if (curCDev.Enabled)
                {
                    Dictionary <AlgorithmType, double> cumulativeSpeeds = new Dictionary <AlgorithmType, double>();
                    var deviceConfig = curCDev.DeviceBenchmarkConfig;
                    foreach (var kvp in deviceConfig.AlgorithmSettings)
                    {
                        var key = kvp.Key;
                        cumulativeSpeeds[key] = 0;
                    }
                    perDeviceTypeBenchmarks[curCDev.UUID] = cumulativeSpeeds;
                }
            }
            // set enabled algorithm count per device counts
            foreach (var curCDev in ComputeDevice.AllAvaliableDevices)
            {
                if (curCDev.Enabled)
                {
                    Dictionary <AlgorithmType, double> cumulativeSpeeds = perDeviceTypeBenchmarks[curCDev.UUID];
                    var deviceConfig = curCDev.DeviceBenchmarkConfig;
                    foreach (var kvp in deviceConfig.AlgorithmSettings)
                    {
                        var key       = kvp.Key;
                        var algorithm = kvp.Value;
                        // check dagger RAM SIZE
                        if (algorithm.Skip ||
                            (algorithm.NiceHashID == AlgorithmType.DaggerHashimoto && !curCDev.IsEtherumCapale))
                        {
                            // for now set to negative value as not profitable
                            cumulativeSpeeds[key]--;
                        }
                        else
                        {
                            cumulativeSpeeds[key]++;
                        }
                    }
                }
            }
            // calculate benchmarks
            foreach (var curCDev in ComputeDevice.AllAvaliableDevices)
            {
                if (curCDev.Enabled)
                {
                    Dictionary <AlgorithmType, double> cumulativeSpeeds = perDeviceTypeBenchmarks[curCDev.UUID];
                    var deviceConfig = curCDev.DeviceBenchmarkConfig;
                    foreach (var kvp in deviceConfig.AlgorithmSettings)
                    {
                        var key       = kvp.Key;
                        var algorithm = kvp.Value;
                        // instead of cumulative speeds get just if enabled or not count x > 0 => enabled; x < 0 => disabled
                        if (cumulativeSpeeds[key] > 0)
                        {
                            cumulativeSpeeds[key] = algorithm.BenchmarkSpeed;
                        }
                        else
                        {
                            cumulativeSpeeds[key] = -1 * algorithm.BenchmarkSpeed;
                        }
                    }
                }
            }

            return(perDeviceTypeBenchmarks);
        }
Esempio n. 4
0
        public bool StartInitialize(IMainFormRatesComunication mainFormRatesComunication,
                                    string miningLocation, string worker, string btcAdress)
        {
            _mainFormRatesComunication = mainFormRatesComunication;
            _miningLocation            = miningLocation;
            _worker    = worker;
            _btcAdress = btcAdress;

            if (_worker.Length > 0)
            {
                _workerBtcStringWorker = _btcAdress + "." + _worker;
            }
            else
            {
                _workerBtcStringWorker = _btcAdress;
            }

            _perDeviceSpeedDictionary = GetEnabledDeviceTypeSpeeds();
            //_groupedDevicesMiners = new Dictionary<GroupedDevices, GroupMiners>();
            _groupedDevicesMiners     = new Dictionary <string, GroupMiners>();
            _enabledDevices           = new List <ComputeDevice>();
            _currentAllGroupedDevices = new AllGroupedDevices();

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


            // this checks if there are enabled devices and enabled algorithms
            bool isMiningEnabled = false;

            foreach (var cdev in ComputeDevice.AllAvaliableDevices)
            {
                if (cdev.Enabled)
                {
                    _enabledDevices.Add(cdev);
                    // check if any algorithm enabled
                    if (!isMiningEnabled)
                    {
                        foreach (var algorithm in cdev.DeviceBenchmarkConfig.AlgorithmSettings)
                        {
                            if (!algorithm.Value.Skip)
                            {
                                isMiningEnabled = true;
                                break;
                            }
                        }
                    }
                }
            }

            if (isMiningEnabled)
            {
                _preventSleepTimer.Start();
                _internetCheckTimer.Start();
            }

            IsCurrentlyIdle = !isMiningEnabled;

            return(isMiningEnabled);
        }