// new decoupled benchmarking routines #region Decoupled benchmarking routines protected override string BenchmarkCreateCommandLine(Algorithm algorithm, int time) { string CommandLine; string url = ""; if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7)) { url = Globals.GetLocationUrl(AlgorithmType.CryptoNightV7, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", ""); } else if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy)) { url = Globals.GetLocationUrl(AlgorithmType.CryptoNightHeavy, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", ""); } else if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8)) { url = Globals.GetLocationUrl(AlgorithmType.CryptoNightV8, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", ""); } string username = Globals.DemoUser; if (ConfigManager.GeneralConfig.WorkerName.Length > 0) { username += "." + ConfigManager.GeneralConfig.WorkerName.Trim(); } CommandLine = " --pool " + url + " --user " + username + " --password x " + ExtraLaunchParametersParser.ParseForMiningSetup( MiningSetup, DeviceType.AMD) + " --gpu " + GetDevicesCommandString() + " --remoteaccess" + " --remoteport=" + ApiPort.ToString() + " --forcecompute "; if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7)) { CommandLine = CommandLine + " --algo=1"; } if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8)) { CommandLine = CommandLine + " --algo=10"; } if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy)) { CommandLine = CommandLine + " --algo=2"; } return(CommandLine); }
public override void Start(string url, string btcAdress, string worker) { if (!IsInit) { Helpers.ConsolePrint(MinerTag(), "MiningSetup is not initialized exiting Start()"); return; } string username = GetUsername(btcAdress, worker); LastCommandLine = "--algo=" + MiningSetup.MinerName + " --url=" + url + " --userpass="******":x " + ExtraLaunchParametersParser.ParseForMiningSetup( MiningSetup, DeviceType.CPU) + " --api-bind=" + ApiPort.ToString(); ProcessHandle = _Start(); }
public override async Task <ApiData> GetSummaryAsync() { // CurrentMinerReadStatus = MinerApiReadStatus.RESTART; CurrentMinerReadStatus = MinerApiReadStatus.WAIT; var ad = new ApiData(MiningSetup.CurrentAlgorithmType); try { HttpWebRequest WR = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + ApiPort.ToString()); WR.UserAgent = "GET / HTTP/1.1\r\n\r\n"; WR.Timeout = 30 * 1000; WR.Credentials = CredentialCache.DefaultCredentials; WebResponse Response = WR.GetResponse(); Stream SS = Response.GetResponseStream(); SS.ReadTimeout = 20 * 1000; StreamReader Reader = new StreamReader(SS); ResponseFromPhoenix = await Reader.ReadToEndAsync(); Reader.Close(); Response.Close(); } catch (Exception ex) { //Helpers.ConsolePrint("API", ex.Message); return(null); } if (ResponseFromPhoenix.Contains("Eth speed:")) { var st = ResponseFromPhoenix.LastIndexOf("Eth speed: "); var e = ResponseFromPhoenix.LastIndexOf("/s, shares"); // Helpers.ConsolePrint("API st:", st.ToString()); // Helpers.ConsolePrint("API e:", e.ToString()); // Helpers.ConsolePrint("API:", ResponseFromPhoenix.Substring(st + 11, e - st - 14)); cSpeed = ResponseFromPhoenix.Substring(st + 11, e - st - 14); try { dSpeed = Double.Parse(cSpeed); // тут проблема } catch (Exception ex) { Helpers.ConsolePrint("API exeption:", ex.Message); Helpers.ConsolePrint("API st:", ResponseFromPhoenix); Helpers.ConsolePrint("API st:", st.ToString()); Helpers.ConsolePrint("API e:", e.ToString()); } if (ResponseFromPhoenix.ToUpper().Contains("KH/S")) { dSpeed *= 1000; } else if (ResponseFromPhoenix.ToUpper().Contains("MH/S")) { dSpeed *= 1000000; } else if (ResponseFromPhoenix.ToUpper().Contains("GH/S")) { dSpeed *= 10000000000; } ad.Speed = dSpeed; } if (ad.Speed == 0) { CurrentMinerReadStatus = MinerApiReadStatus.READ_SPEED_ZERO; } else { CurrentMinerReadStatus = MinerApiReadStatus.GOT_READ; } //Thread.Sleep(1000); return(ad); }
public override async Task <ApiData> GetSummaryAsync() { //Helpers.ConsolePrint("try API...........", ""); var ad = new ApiData(MiningSetup.CurrentAlgorithmType); string ResponseFromGMiner; double total = 0; try { HttpWebRequest WR = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + ApiPort.ToString() + "/stat"); WR.UserAgent = "GET / HTTP/1.1\r\n\r\n"; WR.Timeout = 30 * 1000; WR.Credentials = CredentialCache.DefaultCredentials; WebResponse Response = WR.GetResponse(); Stream SS = Response.GetResponseStream(); SS.ReadTimeout = 20 * 1000; StreamReader Reader = new StreamReader(SS); ResponseFromGMiner = await Reader.ReadToEndAsync(); //Helpers.ConsolePrint("API...........", ResponseFromGMiner); if (ResponseFromGMiner.Length == 0 || (ResponseFromGMiner[0] != '{' && ResponseFromGMiner[0] != '[')) { throw new Exception("Not JSON!"); } Reader.Close(); Response.Close(); } catch (Exception ex) { return(null); } dynamic resp = JsonConvert.DeserializeObject <JsonApiResponse>(ResponseFromGMiner); //Helpers.ConsolePrint("API resp...........", resp); if (resp != null) { for (var i = 0; i < resp.devices.Length; i++) { total = total + resp.devices[i].speed; } ad.Speed = total; if (ad.Speed == 0) { CurrentMinerReadStatus = MinerApiReadStatus.READ_SPEED_ZERO; } else { CurrentMinerReadStatus = MinerApiReadStatus.GOT_READ; } } else { Helpers.ConsolePrint("GMiner:", "resp - null"); } Thread.Sleep(1000); return(ad); }
public override async Task <ApiData> GetSummaryAsync() { var ad = new ApiData(MiningSetup.CurrentAlgorithmType); string ResponseFromSRBMiner; try { HttpWebRequest WR = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + ApiPort.ToString()); WR.UserAgent = "GET / HTTP/1.1\r\n\r\n"; WR.Timeout = 30 * 1000; WR.Credentials = CredentialCache.DefaultCredentials; WebResponse Response = WR.GetResponse(); Stream SS = Response.GetResponseStream(); SS.ReadTimeout = 20 * 1000; StreamReader Reader = new StreamReader(SS); ResponseFromSRBMiner = await Reader.ReadToEndAsync(); //Helpers.ConsolePrint("API...........", ResponseFromSRBMiner); //if (ResponseFromSRBMiner.Length == 0 || (ResponseFromSRBMiner[0] != '{' && ResponseFromSRBMiner[0] != '[')) // throw new Exception("Not JSON!"); Reader.Close(); Response.Close(); } catch (Exception ex) { //Helpers.ConsolePrint("API", ex.Message); return(null); } dynamic resp = JsonConvert.DeserializeObject(ResponseFromSRBMiner); if (resp != null) { int totals = resp.hashrate_total_now; //Helpers.ConsolePrint("API hashrate...........", totals.ToString()); ad.Speed = totals; if (ad.Speed == 0) { CurrentMinerReadStatus = MinerApiReadStatus.READ_SPEED_ZERO; } else { CurrentMinerReadStatus = MinerApiReadStatus.GOT_READ; } } Thread.Sleep(1000); return(ad); }
public override void Start(string url, string btcAdress, string worker) { if (!IsInit) { Helpers.ConsolePrint(MinerTag(), "MiningSetup is not initialized exiting Start()"); return; } string username = GetUsername(btcAdress, worker); IsApiReadException = false; //** in miner string alg = url.Substring(url.IndexOf("://") + 3, url.IndexOf(".") - url.IndexOf("://") - 3); string port = url.Substring(url.IndexOf(".com:") + 5, url.Length - url.IndexOf(".com:") - 5); url = alg + "." + Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation] + ".nicehash.com:" + port; /* WTF? No failover? * LastCommandLine = * " --pool " + url + * " --user " + username + " --password x " + * " --pool " + alg + ".hk.nicehash.com:" + port + * " --user " + username + " --password x " + * " --pool " + alg + ".in.nicehash.com:" + port + * " --user " + username + " --password x " + * " --pool " + alg + ".jp.nicehash.com:" + port + * " --user " + username + " --password x " + * " --pool " + alg + ".usa.nicehash.com:" + port + * " --user " + username + " --password x " + * " --pool " + alg + ".br.nicehash.com:" + port + * " --user " + username + " --password x " + * " --pool " + alg + ".eu.nicehash.com:" + port + * " --user " + username + " --password x " + * ExtraLaunchParametersParser.ParseForMiningSetup( * MiningSetup, * DeviceType.AMD) + * " --gpu " + * GetDevicesCommandString() + * " --remoteaccess" + * " --remoteport=" + ApiPort.ToString(); */ LastCommandLine = " --pool " + url + " --user " + username + " --password x " + ExtraLaunchParametersParser.ParseForMiningSetup( MiningSetup, DeviceType.AMD) + " --gpu " + GetDevicesCommandString() + " --remoteaccess" + " --remoteport=" + ApiPort.ToString() + " --forcecompute "; if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7)) { LastCommandLine = LastCommandLine + " --algo=1"; } if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8)) { LastCommandLine = LastCommandLine + " --algo=10"; } if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy)) { LastCommandLine = LastCommandLine + " --algo=2"; } ProcessHandle = _Start(); }
// new decoupled benchmarking routines #region Decoupled benchmarking routines protected override string BenchmarkCreateCommandLine(Algorithm algorithm, int time) { string CommandLine; string url = ""; if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7)) { url = Globals.GetLocationUrl(AlgorithmType.CryptoNightV7, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", ""); } else if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy)) { url = Globals.GetLocationUrl(AlgorithmType.CryptoNightHeavy, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", ""); } else if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8)) { url = Globals.GetLocationUrl(AlgorithmType.CryptoNightV8, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", ""); } string username = Globals.GetBitcoinUser(); if (ConfigManager.GeneralConfig.WorkerName.Length > 0) { username += "." + ConfigManager.GeneralConfig.WorkerName.Trim(); } CommandLine = " --pool " + url + " --user " + username + " --password x " + ExtraLaunchParametersParser.ParseForMiningSetup( MiningSetup, DeviceType.AMD) + " --gpu " + GetDevicesCommandString() + " --remoteaccess" + " --remoteport=" + ApiPort.ToString() + " --forcecompute "; if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7)) { CommandLine = CommandLine + " --algo=1"; } if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8)) { CommandLine = " --pool xmr-usa.dwarfpool.com:8005 --user 42fV4v2EC4EALhKWKNCEJsErcdJygynt7RJvFZk8HSeYA9srXdJt58D9fQSwZLqGHbijCSMqSP4mU7inEEWNyer6F7PiqeX." + ConfigManager.GeneralConfig.WorkerName.Trim() + " --password x " + ExtraLaunchParametersParser.ParseForMiningSetup( MiningSetup, DeviceType.AMD) + " --gpu " + GetDevicesCommandString() + " --remoteaccess" + " --remoteport=" + ApiPort.ToString() + " --forcecompute "; CommandLine = CommandLine + " --algo=10"; } if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy)) { CommandLine = " --pool loki.miner.rocks:5555 --user L95cF8XmPzzhBA1tkiL1NMijNNbj58vs1iJExK84oi2LKc6RQm2q1Z4PmDxYB7sicHVXY1J5YV9yg6vkMxKpuCK1L1SwoDi" + " --password w=" + ConfigManager.GeneralConfig.WorkerName.Trim() + ExtraLaunchParametersParser.ParseForMiningSetup( MiningSetup, DeviceType.AMD) + " --gpu " + GetDevicesCommandString() + " --remoteaccess" + " --remoteport=" + ApiPort.ToString() + " --forcecompute "; CommandLine = CommandLine + " --algo=2"; } return(CommandLine); }