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); }
private MinerConfiguration CreateMinerConfiguration(int port, string coinSymbol) { CoinConfiguration coinConfiguration = engineConfiguration.CoinConfigurations.Single(c => c.Coin.Symbol.Equals(coinSymbol)); IEnumerable <DeviceConfiguration> coinGpuConfigurations = engineConfiguration.DeviceConfigurations.Where(c => c.Enabled && c.CoinSymbol.Equals(coinSymbol)); MinerConfiguration minerConfiguration = new MinerConfiguration(); minerConfiguration.MinerBackend = engineConfiguration.XgminerConfiguration.MinerBackend; minerConfiguration.ExecutablePath = MinerPath.GetPathToInstalledMiner(minerConfiguration.MinerBackend); minerConfiguration.ErupterDriver = engineConfiguration.XgminerConfiguration.ErupterDriver; minerConfiguration.Pools = coinConfiguration.Pools; minerConfiguration.Algorithm = coinConfiguration.Coin.Algorithm; minerConfiguration.ApiPort = port; minerConfiguration.ApiListen = true; minerConfiguration.AllowedApiIps = engineConfiguration.XgminerConfiguration.AllowedApiIps; minerConfiguration.CoinName = coinConfiguration.Coin.Name; minerConfiguration.DisableGpu = engineConfiguration.XgminerConfiguration.DisableGpu; foreach (DeviceConfiguration coinGpuConfiguration in coinGpuConfigurations) { minerConfiguration.DeviceIndexes.Add(coinGpuConfiguration.DeviceIndex); } string arguments = string.Empty; //apply algorithm-specific parameters if (engineConfiguration.XgminerConfiguration.AlgorithmFlags.ContainsKey(coinConfiguration.Coin.Algorithm)) { arguments = String.Format("{0} {1}", arguments, engineConfiguration.XgminerConfiguration.AlgorithmFlags[coinConfiguration.Coin.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"; } minerConfiguration.Arguments = arguments; return(minerConfiguration); }
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); }
public void StartMining(Data.Configuration.Engine engineConfiguration, List <Xgminer.Data.Device> devices, List <CoinInformation> coinInformation, int donationPercent) { StopMining(); startingMining = true; try { this.engineConfiguration = engineConfiguration; this.devices = devices; this.backendVersion = new Version(Xgminer.Installer.GetInstalledMinerVersion(MinerPath.GetPathToInstalledMiner())); this.donationPercent = donationPercent; if (coinInformation != null) //null if no network connection { ApplyMiningStrategy(coinInformation); } if (!mining) //above call to ApplyMiningStrategy may have started mining due to config change { StartMining(); } mining = true; } finally { startingMining = false; } }
private MinerConfiguration CreateMinerConfiguration(int port, string coinSymbol, DeviceKind includeKinds) { CoinConfiguration coinConfiguration = engineConfiguration.CoinConfigurations.Single(c => c.Coin.Symbol.Equals(coinSymbol)); IList <DeviceConfiguration> enabledConfigurations = engineConfiguration.DeviceConfigurations.Where(c => c.Enabled && c.CoinSymbol.Equals(coinSymbol)).ToList(); MinerConfiguration minerConfiguration = new MinerConfiguration(); minerConfiguration.ExecutablePath = MinerPath.GetPathToInstalledMiner(); //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; if (donating) { minerConfiguration.Pools.First().Quota--; //99% AddDonationPool(coinSymbol, minerConfiguration); } minerConfiguration.Algorithm = coinConfiguration.Coin.Algorithm; minerConfiguration.ApiPort = port; minerConfiguration.ApiListen = true; minerConfiguration.AllowedApiIps = engineConfiguration.XgminerConfiguration.AllowedApiIps; minerConfiguration.CoinName = coinConfiguration.Coin.Name; minerConfiguration.DisableGpu = engineConfiguration.XgminerConfiguration.DisableGpu; int deviceCount = 0; for (int i = 0; i < enabledConfigurations.Count; i++) { DeviceConfiguration enabledConfiguration = enabledConfigurations[i]; Device device = devices.SingleOrDefault(d => d.Equals(enabledConfiguration)); if ((includeKinds & device.Kind) == 0) { continue; } deviceCount++; //don't actually add stratum device as a device index if (device.Kind != DeviceKind.PXY) { minerConfiguration.DeviceDescriptors.Add(device); } else { //only enable the stratum proxy if these devices contain the PXY device minerConfiguration.StratumProxy = engineConfiguration.XgminerConfiguration.StratumProxy; minerConfiguration.StratumProxyPort = engineConfiguration.XgminerConfiguration.StratumProxyPort; minerConfiguration.StratumProxyStratumPort = engineConfiguration.XgminerConfiguration.StratumProxyStratumPort; } } if (deviceCount == 0) { return(null); } string arguments = string.Empty; //apply algorithm-specific parameters if (engineConfiguration.XgminerConfiguration.AlgorithmFlags.ContainsKey(coinConfiguration.Coin.Algorithm)) { arguments = String.Format("{0} {1}", arguments, engineConfiguration.XgminerConfiguration.AlgorithmFlags[coinConfiguration.Coin.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 (donating) { arguments = arguments + " --load-balance"; } minerConfiguration.Arguments = arguments; return(minerConfiguration); }