コード例 #1
0
ファイル: MiningEngine.cs プロジェクト: zwbf/MultiMiner
        private Xgminer.Data.Configuration.Miner CreateMinerConfiguration(int apiPort, string coinSymbol, DeviceKind deviceKind)
        {
            Data.Configuration.Coin coinConfiguration = engineConfiguration.CoinConfigurations.Single(c => c.PoolGroup.Id.Equals(coinSymbol));
            if (coinConfiguration.Pools.Count == 0)
            {
                // no pools configured
                return(null);
            }

            MinerDescriptor miner = MinerFactory.Instance.GetMiner(deviceKind, coinConfiguration.PoolGroup.Algorithm, engineConfiguration.XgminerConfiguration.AlgorithmMiners);

            if (miner == null)
            {
                //no miner configured for the algorithm / custom algorithm
                throw new Xgminer.MinerLaunchException(String.Format("No miner defined for algorithm {0}.", coinConfiguration.PoolGroup.Algorithm));
            }

            Xgminer.Data.Configuration.Miner minerConfiguration = CreateBasicConfiguration(miner, coinConfiguration, apiPort);

            IList <Engine.Data.Configuration.Device> enabledConfigurations =
                engineConfiguration.DeviceConfigurations
                .Where(c => c.Enabled && c.CoinSymbol.Equals(coinSymbol)).ToList();

            int deviceCount = SetupConfigurationDevices(minerConfiguration, deviceKind, enabledConfigurations);

            if (deviceCount == 0)
            {
                return(null);
            }

            return(minerConfiguration);
        }
コード例 #2
0
ファイル: MiningEngine.cs プロジェクト: hoanvls/MultiMiner
        private Xgminer.Data.Configuration.Miner CreateMinerConfiguration(int apiPort, string coinSymbol, DeviceKind deviceKind)
        {
            Data.Configuration.Coin coinConfiguration = engineConfiguration.CoinConfigurations.Single(c => c.CryptoCoin.Symbol.Equals(coinSymbol));
            if (coinConfiguration.Pools.Count == 0)
            {
                // no pools configured
                return(null);
            }

            MinerDescriptor miner = MinerFactory.Instance.GetMiner(deviceKind, coinConfiguration.CryptoCoin.Algorithm, engineConfiguration.XgminerConfiguration.AlgorithmMiners);

            Xgminer.Data.Configuration.Miner minerConfiguration = CreateBasicConfiguration(miner, coinConfiguration, apiPort);

            IList <Engine.Data.Configuration.Device> enabledConfigurations =
                engineConfiguration.DeviceConfigurations
                .Where(c => c.Enabled && c.CoinSymbol.Equals(coinSymbol)).ToList();

            int deviceCount = SetupConfigurationDevices(minerConfiguration, deviceKind, enabledConfigurations);

            if (deviceCount == 0)
            {
                return(null);
            }

            return(minerConfiguration);
        }
コード例 #3
0
        private Xgminer.Data.Configuration.Miner CreateMinerConfiguration(int port, string coinSymbol, DeviceKind includeKinds)
        {
            Data.Configuration.Coin coinConfiguration = engineConfiguration.CoinConfigurations.Single(c => c.CryptoCoin.Symbol.Equals(coinSymbol));

            IList <Engine.Data.Configuration.Device> enabledConfigurations = engineConfiguration.DeviceConfigurations.Where(c => c.Enabled && c.CoinSymbol.Equals(coinSymbol)).ToList();

            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath = MinerPath.GetPathToInstalledMiner(),
                Algorithm      = coinConfiguration.CryptoCoin.Algorithm,
                ApiPort        = port,
                ApiListen      = true,
                AllowedApiIps  = engineConfiguration.XgminerConfiguration.AllowedApiIps,
                CoinName       = coinConfiguration.CryptoCoin.Name,
                DisableGpu     = engineConfiguration.XgminerConfiguration.DisableGpu
            };

            SetupConfigurationPools(minerConfiguration, coinConfiguration);

            int deviceCount = SetupConfigurationDevices(minerConfiguration, includeKinds, enabledConfigurations);

            if (deviceCount == 0)
            {
                return(null);
            }

            SetupConfigurationArguments(minerConfiguration, coinConfiguration);

            return(minerConfiguration);
        }
コード例 #4
0
        private void userNameCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            MiningPool currentPool = (MiningPool)miningPoolBindingSource.Current;

            if (currentPool == null)
            {
                return;
            }

            //if the password is blank
            if (String.IsNullOrEmpty(currentPool.Password))
            {
                //and a workername is selected
                if (userNameCombo.SelectedItem != null)
                {
                    string workerName = (string)userNameCombo.SelectedItem;
                    MultiMiner.Engine.Data.Configuration.Coin configuration = configurations
                                                                              .FirstOrDefault(c => c.Pools.Any(p => p.Username.Equals(workerName)));

                    //default to the password used for the same worker on another config
                    if (configuration != null)
                    {
                        currentPool.Password = configuration.Pools.First(p => p.Username.Equals(workerName)).Password;
                    }
                }
            }
        }
コード例 #5
0
ファイル: MiningEngine.cs プロジェクト: hoanvls/MultiMiner
        private Xgminer.Data.Configuration.Miner CreateProxyConfiguration(int apiPort, string coinSymbol)
        {
            Data.Configuration.Coin coinConfiguration = engineConfiguration.CoinConfigurations.Single(c => c.CryptoCoin.Symbol.Equals(coinSymbol));
            if (coinConfiguration.Pools.Count == 0)
            {
                // no pools configured
                return(null);
            }

            //BFGMiner for proxying
            MinerDescriptor miner = MinerFactory.Instance.GetDefaultMiner();

            return(CreateBasicConfiguration(miner, coinConfiguration, apiPort));
        }
コード例 #6
0
        private void copyCoinButton_Click(object sender, EventArgs e)
        {
            CoinChooseForm coinChooseForm = new CoinChooseForm(knownCoins);
            DialogResult   dialogResult   = coinChooseForm.ShowDialog();

            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                PoolGroup destinationCoin = coinChooseForm.SelectedCoin;

                Engine.Data.Configuration.Coin sourceConfiguration = configurations[coinListBox.SelectedIndex];

                MultiMiner.Engine.Data.Configuration.Coin destinationConfiguration = AddCoinConfiguration(destinationCoin);

                ObjectCopier.CopyObject(sourceConfiguration, destinationConfiguration, "CryptoCoin");

                BindToCurrentConfiguration();
                coinConfigurationBindingSource.ResetBindings(false);
                miningPoolBindingSource.ResetBindings(false);
            }
        }
コード例 #7
0
ファイル: MiningEngine.cs プロジェクト: hoanvls/MultiMiner
        private void ApplyProfitabilityAdjustments(IEnumerable <CoinInformation> coinInformation)
        {
            foreach (CoinInformation configuredProfitableCoin in coinInformation)
            {
                Data.Configuration.Coin coinConfiguration = engineConfiguration.CoinConfigurations.Single(c => c.CryptoCoin.Symbol.Equals(configuredProfitableCoin.Symbol));

                if (coinConfiguration.ProfitabilityAdjustmentType == Data.Configuration.Coin.AdjustmentType.Addition)
                {
                    configuredProfitableCoin.AdjustedProfitability += coinConfiguration.ProfitabilityAdjustment;
                    configuredProfitableCoin.AverageProfitability  += coinConfiguration.ProfitabilityAdjustment;
                    configuredProfitableCoin.Profitability         += coinConfiguration.ProfitabilityAdjustment;
                }
                else if (coinConfiguration.ProfitabilityAdjustmentType == Data.Configuration.Coin.AdjustmentType.Multiplication)
                {
                    configuredProfitableCoin.AdjustedProfitability *= coinConfiguration.ProfitabilityAdjustment;
                    configuredProfitableCoin.AverageProfitability  *= coinConfiguration.ProfitabilityAdjustment;
                    configuredProfitableCoin.Profitability         *= coinConfiguration.ProfitabilityAdjustment;
                }
            }
        }
コード例 #8
0
ファイル: MiningEngine.cs プロジェクト: hoanvls/MultiMiner
        private readonly Random random = new Random(Guid.NewGuid().GetHashCode()); //seed so we don't keep getting the same indexes
        private void AddDonationPool(string coinSymbol, Xgminer.Data.Configuration.Miner minerConfiguration)
        {
            MiningPool donationPool = null;

            Data.Configuration.Coin donationConfiguration = this.donationConfigurations.SingleOrDefault(dc => dc.CryptoCoin.Symbol.Equals(coinSymbol, StringComparison.OrdinalIgnoreCase));
            if (donationConfiguration != null)
            {
                //inclusive lower, exclusive upper
                //int index = random.Next(0, donationConfiguration.Pools.Count);

                //for now just use the first pool, too many donors is *not* an issue
                //if it becomes an issue we can revert to the above
                int index = 0;
                donationPool = donationConfiguration.Pools[index];
            }

            if (donationPool != null)
            {
                donationPool.Quota = donationPercent;
                minerConfiguration.Pools.Add(donationPool);
            }
        }
コード例 #9
0
ファイル: MiningEngine.cs プロジェクト: hoanvls/MultiMiner
        private Xgminer.Data.Configuration.Miner CreateBasicConfiguration(
            MinerDescriptor miner,
            Data.Configuration.Coin coinConfiguration,
            int apiPort)
        {
            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath = MinerPath.GetPathToInstalledMiner(miner),
                Algorithm      = coinConfiguration.CryptoCoin.Algorithm,
                ApiPort        = apiPort,
                ApiListen      = true,
                AllowedApiIps  = engineConfiguration.XgminerConfiguration.AllowedApiIps,
                CoinName       = coinConfiguration.CryptoCoin.Name,
                DisableGpu     = engineConfiguration.XgminerConfiguration.DisableGpu
            };

            SetupConfigurationPools(minerConfiguration, coinConfiguration);

            SetupConfigurationArguments(minerConfiguration, coinConfiguration);

            return(minerConfiguration);
        }
コード例 #10
0
 private void SetCoinConfigurationOnAllRigs(Coin[] coinConfigurations)
 {
     //call ToList() so we can get a copy - otherwise risk:
     //System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
     List<Instance> instancesCopy = InstanceManager.Instances.Where(i => i != InstanceManager.ThisPCInstance).ToList();
     foreach (Instance instance in instancesCopy)
     {
         Instance closedInstance = instance;
         PerformRemoteCommand(instance, service =>
         {
             service.SetCoinConfigurations(GetSendingSignature(closedInstance), coinConfigurations);
         });
     }
 }
コード例 #11
0
        private void SetCoinConfigurationsRequested(object sender, Coin[] coinConfigurations, RemoteCommandEventArgs ea)
        {
            PerformRequestedCommand(ea.IpAddress, ea.Signature, () =>
            {
                ObjectCopier.CopyObject(coinConfigurations, EngineConfiguration.CoinConfigurations);
                EngineConfiguration.SaveCoinConfigurations();

                Context.BeginInvoke((Action)(() =>
                {
                    //code to update UI
                    LocalViewModel.ApplyCoinConfigurationModels(EngineConfiguration.CoinConfigurations);
                    LocalViewModel.ApplyDeviceConfigurationModels(EngineConfiguration.DeviceConfigurations,
                        EngineConfiguration.CoinConfigurations);
                    if (ConfigurationModified != null) ConfigurationModified(this, new EventArgs());
                }), null);
            });
        }
コード例 #12
0
        private static string GetPoolNameByIndex(Coin coinConfiguration, int poolIndex)
        {
            string result = String.Empty;

            if (poolIndex >= 0)
            {
                if (coinConfiguration != null)
                {
                    //the poolIndex may be greater than the Pools count if donating
                    if (poolIndex < coinConfiguration.Pools.Count)
                    {
                        result = coinConfiguration.Pools[poolIndex].Host;
                    }
                }
            }

            return result;
        }
コード例 #13
0
        public MiningPool FindPoolConfiguration(Coin coinConfig, string url, string user)
        {
            MiningPool poolConfig = coinConfig.Pools.FirstOrDefault((p) =>
            {
                //url may or may not have protocol, but URI ctor requires one
                //so strip any that exists with ShortHostFromHost() then add a dummy
                Uri uri = new Uri("http://" + url.ShortHostFromHost());

                var cleanUri = uri.GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port,
                               UriFormat.UriEscaped);

                var portsEqual = (p.Port == uri.Port);
                var hostsEqual = (p.Host.ShortHostFromHost().Equals(cleanUri.ShortHostFromHost(), StringComparison.OrdinalIgnoreCase));
                var usersEqual = (string.IsNullOrEmpty(user) || p.Username.Equals(user, StringComparison.OrdinalIgnoreCase));

                return portsEqual
                    && hostsEqual
                    && usersEqual;
            });
            return poolConfig;
        }
コード例 #14
0
ファイル: MiningEngine.cs プロジェクト: hoanvls/MultiMiner
        private void SetupConfigurationPools(Xgminer.Data.Configuration.Miner minerConfiguration, Data.Configuration.Coin coinConfiguration)
        {
            //minerConfiguration.Pools = coinConfiguration.Pools;
            foreach (MiningPool pool in coinConfiguration.Pools)
            {
                pool.Quota = 0;
                minerConfiguration.Pools.Add(pool);
            }

            //using bfgminer quotas for failover, that way we can augment for donations
            minerConfiguration.Pools.First().Quota = 100 - donationPercent;
            if (donationPercent > 0)
            {
                AddDonationPool(coinConfiguration.CryptoCoin.Symbol, minerConfiguration);
            }

            foreach (MiningPool pool in minerConfiguration.Pools)
            {
                pool.QuotaEnabled = donationPercent > 0;
            }
        }
コード例 #15
0
ファイル: MiningEngine.cs プロジェクト: hoanvls/MultiMiner
        private void SetupConfigurationArguments(Xgminer.Data.Configuration.Miner minerConfiguration, Data.Configuration.Coin coinConfiguration)
        {
            string arguments = string.Empty;

            //apply algorithm-specific parameters
            if (engineConfiguration.XgminerConfiguration.AlgorithmFlags.ContainsKey(coinConfiguration.CryptoCoin.Algorithm))
            {
                arguments = String.Format("{0} {1}", arguments,
                                          engineConfiguration.XgminerConfiguration.AlgorithmFlags[coinConfiguration.CryptoCoin.Algorithm]);
            }

            //apply coin-specific parameters
            if (!string.IsNullOrEmpty(coinConfiguration.MinerFlags))
            {
                arguments = string.Format("{0} {1}", arguments, coinConfiguration.MinerFlags);
            }

            if (engineConfiguration.XgminerConfiguration.DesktopMode)
            {
                arguments = arguments + " -I D";
            }

            if (donationPercent > 0)
            {
                arguments = arguments + " --load-balance";
            }

            minerConfiguration.LaunchArguments = arguments;
        }
コード例 #16
0
ファイル: PoolsForm.cs プロジェクト: 27miller87/MultiMiner
        private void EditCurrentCoin(Coin currentConfiguration)
        {
            PoolGroup workingCoin = new PoolGroup();
            ObjectCopier.CopyObject(currentConfiguration.PoolGroup, workingCoin);

            using (CoinEditForm coinEditForm = new CoinEditForm(workingCoin))
            {
                DialogResult dialogResult = coinEditForm.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    Coin existingConfiguration =
                        configurations.SingleOrDefault(c => (c != currentConfiguration)
                            && c.PoolGroup.Id.Equals(workingCoin.Id, StringComparison.OrdinalIgnoreCase));

                    if (existingConfiguration == null)
                    {
                        ObjectCopier.CopyObject(workingCoin, currentConfiguration.PoolGroup);
                        coinListBox.Items[coinListBox.SelectedIndex] = workingCoin.Name;
                    }
                    else
                    {
                        //don't create a dupe
                        MessageBox.Show(String.Format("A configuration for {0} already exists.", workingCoin.Id),
                            "Duplicate Configuration", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
コード例 #17
0
ファイル: MiningEngine.cs プロジェクト: hoanvls/MultiMiner
        private List <Engine.Data.Configuration.Device> CreateDeviceConfigurationForProfitableCoins(List <CoinInformation> allProfitableCoins,
                                                                                                    List <CoinInformation> sha256ProfitableCoins, List <CoinInformation> scryptProfitableCoins)
        {
            List <Engine.Data.Configuration.Device> newConfiguration = new List <Engine.Data.Configuration.Device>();
            CoinInformation profitableCoin = null;

            int comboAlgoIterator = 0;
            int sha256Iterator    = 0;
            int scryptIterator    = 0;

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

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

                if (existingConfiguration.Enabled)
                {
                    profitableCoin = null;

                    if (device.Kind == DeviceKind.PXY)
                    {
                        Data.Configuration.Coin existingCoinConfig = engineConfiguration.CoinConfigurations.Single(cc => cc.CryptoCoin.Symbol.Equals(existingConfiguration.CoinSymbol, StringComparison.OrdinalIgnoreCase));

                        //keep Proxies on the same algo - don't know what is pointed at them
                        if (existingCoinConfig.CryptoCoin.Algorithm == CoinAlgorithm.Scrypt)
                        {
                            profitableCoin = ChooseCoinFromList(scryptProfitableCoins, scryptIterator);

                            scryptIterator++;
                        }
                        else
                        {
                            profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, sha256Iterator);

                            sha256Iterator++;
                        }
                    }
                    else if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && !device.SupportsAlgorithm(CoinAlgorithm.SHA256))
                    {
                        //scrypt only
                        profitableCoin = ChooseCoinFromList(scryptProfitableCoins, scryptIterator);

                        scryptIterator++;
                    }
                    else if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && device.SupportsAlgorithm(CoinAlgorithm.SHA256))
                    {
                        //sha256 or scrypt
                        profitableCoin = ChooseCoinFromList(allProfitableCoins, comboAlgoIterator);

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

                        sha256Iterator++;
                    }

                    if (comboAlgoIterator >= allProfitableCoins.Count())
                    {
                        comboAlgoIterator = 0;
                    }
                    if (sha256Iterator >= sha256ProfitableCoins.Count())
                    {
                        sha256Iterator = 0;
                    }
                    if (scryptIterator >= scryptProfitableCoins.Count())
                    {
                        scryptIterator = 0;
                    }

                    Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device();

                    configEntry.Assign(device);

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

                    newConfiguration.Add(configEntry);
                }
                else
                {
                    Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device();

                    configEntry.Assign(device);

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

                    newConfiguration.Add(configEntry);
                }
            }

            return(newConfiguration);
        }