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);
        }