Ejemplo n.º 1
0
        private List <DeviceConfiguration> CreateDeviceConfigurationForProfitableCoins(List <CoinInformation> allProfitableCoins, List <CoinInformation> sha256ProfitableCoins)
        {
            List <DeviceConfiguration> newConfiguration = new List <DeviceConfiguration>();
            CoinInformation            profitableCoin   = null;

            int gpuIterator = 0;
            int amuIterator = 0;

            for (int i = 0; i < devices.Count; i++)
            {
                Device device = devices[i];

                //there should be a 1-to-1 relationship of devices and device configurations
                DeviceConfiguration existingConfiguration = engineConfiguration.DeviceConfigurations[i];

                if (existingConfiguration.Enabled)
                {
                    profitableCoin = null;

                    if (device.Kind == DeviceKind.GPU)
                    {
                        //sha256 or scrypt
                        profitableCoin = ChooseCoinFromList(allProfitableCoins, gpuIterator);

                        gpuIterator++;
                        if (gpuIterator >= allProfitableCoins.Count())
                        {
                            gpuIterator = 0;
                        }
                    }
                    else if (sha256ProfitableCoins.Count > 0)
                    {
                        //sha256 only
                        profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, amuIterator);

                        amuIterator++;
                        if (amuIterator >= sha256ProfitableCoins.Count())
                        {
                            amuIterator = 0;
                        }
                    }

                    DeviceConfiguration configEntry = new DeviceConfiguration();

                    configEntry.Assign(device);

                    configEntry.CoinSymbol = profitableCoin == null ? string.Empty : profitableCoin.Symbol;

                    newConfiguration.Add(configEntry);
                }
                else
                {
                    DeviceConfiguration configEntry = new DeviceConfiguration();

                    configEntry.Assign(device);

                    configEntry.CoinSymbol = existingConfiguration.CoinSymbol;
                    configEntry.Enabled    = false;

                    newConfiguration.Add(configEntry);
                }
            }

            return(newConfiguration);
        }