public MinerDescriptor RegisterMiner(string name, string fileName, bool legacyApi) { MinerDescriptor miner = new MinerDescriptor() { Name = name, FileName = fileName, LegacyApi = legacyApi }; Miners.Add(miner); return miner; }
public static string GetPathToInstalledMiner(MinerDescriptor miner) { string executablePath = string.Empty; switch (OSVersionPlatform.GetConcretePlatform()) { case PlatformID.MacOSX: executablePath = GetPathToMinerOnMacOSX(miner.Name, miner.FileName); break; //support Unix - there is no bin folder for the executables like on Mac OS X case PlatformID.Unix: //file launching is case-sensitive, lower-case the filename executablePath = GetPathToMinerOnLinux(miner.FileName, miner.FileName.ToLower()); break; default: executablePath = GetPathToMinerOnWindows(miner.Name, miner.FileName); break; } return executablePath; }
public List<Device> GetDevices(MinerDescriptor minerDescriptor, string executablePath) { Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner() { ExecutablePath = executablePath, DisableGpu = xgminerConfiguration.DisableGpu, DisableUsbProbe = xgminerConfiguration.DisableUsbProbe, ScanArguments = xgminerConfiguration.ScanArguments }; Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration, false); Version minerVersion = new Version(MinerInstaller.GetInstalledMinerVersion(executablePath, false)); List<Device> detectedDevices = miner.ListDevices(true, minerVersion); if (xgminerConfiguration.StratumProxy) { for (int i = 0; i < xgminerConfiguration.StratumProxies.Count; i++) { MultiMiner.Engine.Data.Configuration.Xgminer.ProxyDescriptor proxy = xgminerConfiguration.StratumProxies[i]; detectedDevices.Add(new Device() { Kind = DeviceKind.PXY, Driver = "proxy", Name = String.Format("Stratum Proxy #{0}", (i + 1)), //we want the path in the ViewModel for Remoting //can't rely on having the Stratum Proxy settings Path = String.Format("{0}:{1}", proxy.GetworkPort, proxy.StratumPort), RelativeIndex = i }); } } SortDevices(detectedDevices); return detectedDevices; }
private static bool MinerIsInstalled(MinerDescriptor miner) { string path = MinerPath.GetPathToInstalledMiner(miner); return File.Exists(path); }
private void InstallBackendMinerLocally(MinerDescriptor miner) { string minerName = miner.Name; ProgressForm progressForm = new ProgressForm(String.Format("Downloading and installing {0} from {1}", minerName, new Uri(miner.Url).Authority)); progressForm.Show(); //for Mono - show the UI System.Windows.Forms.Application.DoEvents(); Thread.Sleep(25); System.Windows.Forms.Application.DoEvents(); try { string minerPath = Path.Combine("Miners", minerName); string destinationFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, minerPath); MinerInstaller.InstallMiner(UserAgent.AgentString, miner, destinationFolder); //may have been installed via Remoting - dismiss notification notificationsControl.RemoveNotification(bfgminerNotificationId.ToString()); } finally { progressForm.Close(); } }
private static bool ConfigFileHandledForMiner(MinerDescriptor miner) { const string bakExtension = ".mmbak"; string minerName = miner.Name; string minerExecutablePath = MinerPath.GetPathToInstalledMiner(miner); string confFileFilePath = String.Empty; if (OSVersionPlatform.GetGenericPlatform() == PlatformID.Unix) { string minerFolderName = "." + minerName; string minerFileName = minerName + ".conf"; confFileFilePath = Path.Combine(Path.Combine(OSVersionPlatform.GetHomeDirectoryPath(), minerFolderName), minerFileName); } else { confFileFilePath = Path.ChangeExtension(minerExecutablePath, ".conf"); } if (File.Exists(confFileFilePath)) { string confFileName = Path.GetFileName(confFileFilePath); string confBakFileName = confFileName + bakExtension; DialogResult dialogResult = MessageBox.Show(String.Format("A {0} file has been detected in your miner directory. This file interferes with the arguments supplied by MultiMiner. Can MultiMiner rename this file to {1}?", confFileName, confBakFileName), "External Configuration Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == System.Windows.Forms.DialogResult.No) return false; string confBakFileFilePath = confFileFilePath + bakExtension; File.Delete(confBakFileFilePath); File.Move(confFileFilePath, confBakFileFilePath); } return true; }
private void CheckAndDownloadMiner(MinerDescriptor miner) { string installedFilePath = MinerPath.GetPathToInstalledMiner(miner); if (!File.Exists(installedFilePath)) InstallBackendMinerLocally(miner); }
public void InstallBackendMinerLocally(MinerDescriptor miner) { string minerName = miner.Name; if (ProgressStarted != null) ProgressStarted(this, new ProgressEventArgs { Text = String.Format("Downloading and installing {0} from {1}", minerName, new Uri(miner.Url).Authority) }); try { string minerPath = System.IO.Path.Combine("Miners", minerName); string destinationFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, minerPath); try { MinerInstaller.InstallMiner(UserAgent.AgentString, miner, destinationFolder); //may have been installed via Remoting - dismiss notification if (NotificationDismissed != null) NotificationDismissed(this, new NotificationEventArgs { Id = BfgMinerNotificationId.ToString() }); } catch (NotImplementedException) { //don't crash on *nix when downloads get triggered PostNotification("Auto installation not supported for your OS", () => { MessageBoxShow( String.Format("You must install {0} for your OS manually.", miner.Name), "Not Implemented", PromptButtons.OK, PromptIcon.Warning); }, NotificationKind.Warning); } } finally { if (ProgressCompleted != null) ProgressCompleted(this, new EventArgs()); } }
private MinerProcess StoreMinerProcess(Process process, MinerDescriptor miner, string coinSymbol, Xgminer.Data.Configuration.Miner minerConfiguration, int apiPort) { MinerProcess minerProcess = new MinerProcess() { Process = process, Miner = miner, ApiPort = apiPort, MinerConfiguration = minerConfiguration, CoinSymbol = coinSymbol }; setupProcessStartInfo(minerProcess); minerProcesses.Add(minerProcess); return minerProcess; }
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; }