diff --git a/zPoolMiner/Algorithm.cs b/zPoolMiner/Algorithm.cs index b8bdc13..16ddbad 100644 --- a/zPoolMiner/Algorithm.cs +++ b/zPoolMiner/Algorithm.cs @@ -132,7 +132,7 @@ public Algorithm(MinerBaseType minerBaseType, AlgorithmType cryptominer937ID, st LessThreads = 1; Enabled = !(CryptoMiner937ID == AlgorithmType.Nist5 || CryptoMiner937ID == AlgorithmType.Skein || CryptoMiner937ID == AlgorithmType.Blake2s || CryptoMiner937ID == AlgorithmType.Phi) && minerBaseType == MinerBaseType.sgminer; Enabled = !(CryptoMiner937ID == AlgorithmType.cryptonight) || (CryptoMiner937ID == AlgorithmType.Keccak) && minerBaseType == MinerBaseType.GatelessGate; - Enabled = !(CryptoMiner937ID == AlgorithmType.karlsenhash) || (CryptoMiner937ID == AlgorithmType.pyrinhash) || (CryptoMiner937ID == AlgorithmType.ethash) || (CryptoMiner937ID == AlgorithmType.ethashb3) && minerBaseType == MinerBaseType.lolMiner; + Enabled = !(CryptoMiner937ID == AlgorithmType.karlsenhash) || (CryptoMiner937ID == AlgorithmType.pyrinhash) || (CryptoMiner937ID == AlgorithmType.ethash) || (CryptoMiner937ID == AlgorithmType.ethashb3) && minerBaseType == MinerBaseType.lolMinerAmd; BenchmarkStatus = ""; } diff --git a/zPoolMiner/Devices/GroupAlgorithms.cs b/zPoolMiner/Devices/GroupAlgorithms.cs index 803ea65..5102549 100644 --- a/zPoolMiner/Devices/GroupAlgorithms.cs +++ b/zPoolMiner/Devices/GroupAlgorithms.cs @@ -238,7 +238,7 @@ private static Dictionary> CreateForDevice(Comput algo.Enabled = false; } } - if (algoSettings.ContainsKey(MinerBaseType.lolMiner)) + if (algoSettings.ContainsKey(MinerBaseType.lolMinerAmd)) { } @@ -476,12 +476,12 @@ public static Dictionary> CreateDefaultsForGroup( new List { new Algorithm(MinerBaseType.XmrStakAMD, AlgorithmType.cryptonight, "") } - }*/{MinerBaseType.lolMiner, + }*/{MinerBaseType.lolMinerAmd, new List() { - new Algorithm(MinerBaseType.lolMiner,AlgorithmType.karlsenhash,"karlsenhash"), - new Algorithm(MinerBaseType.lolMiner,AlgorithmType.pyrinhash,"pyrinhash"), - new Algorithm(MinerBaseType.lolMiner,AlgorithmType.ethash,"ethash"), - new Algorithm(MinerBaseType.lolMiner,AlgorithmType.ethashb3,"ethashb3") + new Algorithm(MinerBaseType.lolMinerAmd,AlgorithmType.karlsenhash,"karlsenhash"), + new Algorithm(MinerBaseType.lolMinerAmd,AlgorithmType.pyrinhash,"pyrinhash"), + new Algorithm(MinerBaseType.lolMinerAmd,AlgorithmType.ethash,"ethash"), + new Algorithm(MinerBaseType.lolMinerAmd,AlgorithmType.ethashb3,"ethashb3") } } }; diff --git a/zPoolMiner/Enums/MinerBaseType.cs b/zPoolMiner/Enums/MinerBaseType.cs index d23e713..afdc2ad 100644 --- a/zPoolMiner/Enums/MinerBaseType.cs +++ b/zPoolMiner/Enums/MinerBaseType.cs @@ -141,7 +141,7 @@ public enum MinerBaseType /// experimental, - lolMiner, + lolMinerAmd, /// /// Defines the EWBF /// diff --git a/zPoolMiner/Enums/MinerType.cs b/zPoolMiner/Enums/MinerType.cs index 406af65..7bcd9e4 100644 --- a/zPoolMiner/Enums/MinerType.cs +++ b/zPoolMiner/Enums/MinerType.cs @@ -111,7 +111,7 @@ public enum MinerType /// Defines the Xmrig /// Xmrig, - lolMiner, + lolMinerAmd, /// /// Defines the Palgin_Neoscrypt /// diff --git a/zPoolMiner/Miners/AMD/lolminer.cs b/zPoolMiner/Miners/AMD/lolminerAmd.cs similarity index 98% rename from zPoolMiner/Miners/AMD/lolminer.cs rename to zPoolMiner/Miners/AMD/lolminerAmd.cs index 942c45f..09b2264 100644 --- a/zPoolMiner/Miners/AMD/lolminer.cs +++ b/zPoolMiner/Miners/AMD/lolminerAmd.cs @@ -19,14 +19,14 @@ namespace NiceHashMiner.Miners { - class lolMiner : Miner + class lolMinerAmd : Miner { private readonly int GPUPlatformNumber; Stopwatch _benchmarkTimer = new Stopwatch(); int count = 0; double speed = 0; - public lolMiner() + public lolMinerAmd() : base("lolMiner_AMD") { GPUPlatformNumber = ComputeDeviceManager.Avaliable.AMDOpenCLPlatformNum; @@ -260,7 +260,7 @@ public class lolGpuResult public override async Task GetSummaryAsync() { var ad = new APIData(MiningSetup.CurrentAlgorithmType); - string ResponseFromlolMiner; + string ResponseFromlolMinerAmd; try { HttpWebRequest WR = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + ApiPort.ToString() + "/summary"); @@ -271,8 +271,8 @@ public override async Task GetSummaryAsync() Stream SS = Response.GetResponseStream(); SS.ReadTimeout = 2 * 1000; StreamReader Reader = new StreamReader(SS); - ResponseFromlolMiner = await Reader.ReadToEndAsync(); - //Helpers.ConsolePrint("API: ", ResponseFromlolMiner); + ResponseFromlolMinerAmd = await Reader.ReadToEndAsync(); + //Helpers.ConsolePrint("API: ", ResponseFromlolMinerAmd); //if (ResponseFromlolMiner.Length == 0 || (ResponseFromlolMiner[0] != '{' && ResponseFromlolMiner[0] != '[')) // throw new Exception("Not JSON!"); Reader.Close(); @@ -283,14 +283,14 @@ public override async Task GetSummaryAsync() return null; } - if (ResponseFromlolMiner == null) + if (ResponseFromlolMinerAmd == null) { CurrentMinerReadStatus = MinerApiReadStatus.NONE; return null; } try { - dynamic resp = JsonConvert.DeserializeObject(ResponseFromlolMiner); + dynamic resp = JsonConvert.DeserializeObject(ResponseFromlolMinerAmd); int mult = 1; if (resp != null) { diff --git a/zPoolMiner/Miners/Grouping/MinerPaths.cs b/zPoolMiner/Miners/Grouping/MinerPaths.cs index c532aa9..c8c788e 100644 --- a/zPoolMiner/Miners/Grouping/MinerPaths.cs +++ b/zPoolMiner/Miners/Grouping/MinerPaths.cs @@ -223,7 +223,7 @@ public static class Data /// //public const string ccminer_xevan = _bin + @"\ccminer_xevan\ccminer.exe"; - public const string lolMiner = _bin + @"\lolMiner\lolMiner.exe"; + public const string lolMinerAmd = _bin + @"\lolMiner\lolMiner.exe"; /// /// CPUminers /// @@ -453,8 +453,8 @@ public static string GetPathFor(MinerBaseType minerBaseType, AlgorithmType algoT return NVIDIA_GROUPS.CryptoDredge(algoType, devGroupType); case MinerBaseType.CPU_verium: return Data.CPU_verium; - case MinerBaseType.lolMiner: - return AMD_GROUP.lolMiner(algoType); + case MinerBaseType.lolMinerAmd: + return AMD_GROUP.lolMinerAmd(algoType); } return Data.NONE; } @@ -751,19 +751,19 @@ public static string Sgminer_path(AlgorithmType type) } if (AlgorithmType.karlsenhash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.pyrinhash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.ethash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.ethashb3 == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } /*if (AlgorithmType.x16r == type) { @@ -772,27 +772,27 @@ public static string Sgminer_path(AlgorithmType type) return Data.NONE; } - public static string lolMiner_path(AlgorithmType type) + public static string lolMinerAmd_path(AlgorithmType type) { if (AlgorithmType.karlsenhash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.pyrinhash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.ethash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.ethashb3 == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } - return Data.lolMiner; + return Data.lolMinerAmd; } /// @@ -810,23 +810,23 @@ public static string Glg_path(AlgorithmType type) return Data.NONE; } - public static string lolMiner(AlgorithmType type) + public static string lolMinerAmd(AlgorithmType type) { if (AlgorithmType.karlsenhash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.pyrinhash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.ethash == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } if (AlgorithmType.ethashb3 == type) { - return Data.lolMiner; + return Data.lolMinerAmd; } return Data.NONE; } diff --git a/zPoolMiner/Miners/MinerFactory.cs b/zPoolMiner/Miners/MinerFactory.cs index d0d6c3c..6a7b23b 100644 --- a/zPoolMiner/Miners/MinerFactory.cs +++ b/zPoolMiner/Miners/MinerFactory.cs @@ -100,8 +100,8 @@ public static Miner CreateMiner(DeviceType deviceType, AlgorithmType algorithmTy case MinerBaseType.Claymore: return CreateClaymore(algorithmType, secondaryAlgorithmType); - case MinerBaseType.lolMiner: - return new lolMiner(); + case MinerBaseType.lolMinerAmd: + return new lolMinerAmd(); case MinerBaseType.OptiminerAMD: return new OptiminerZcashMiner(); diff --git a/zPoolMiner/Miners/Nvidia/lolminerNvidia.cs b/zPoolMiner/Miners/Nvidia/lolminerNvidia.cs new file mode 100644 index 0000000..386f870 --- /dev/null +++ b/zPoolMiner/Miners/Nvidia/lolminerNvidia.cs @@ -0,0 +1,345 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using zPoolMiner; +using zPoolMiner.Configs; +using zPoolMiner.Devices; +using zPoolMiner.Enums; +using zPoolMiner.Miners; +using zPoolMiner.Miners.Grouping; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace NiceHashMiner.Miners +{ + class lolMinerNvidia : Miner + { + private readonly int GPUPlatformNumber; + Stopwatch _benchmarkTimer = new Stopwatch(); + int count = 0; + double speed = 0; + + public lolMinerNvidia() + : base("lolMiner_Nvidia") + { + GPUPlatformNumber = ComputeDeviceManager.Avaliable.AMDOpenCLPlatformNum; + IsKillAllUsedMinerProcs = true; + IsNeverHideMiningWindow = true; + + } + + protected override int GetMaxCooldownTimeInMilliseconds() + { + return 60 * 1000; + } + + protected override void _Stop(MinerStopType willswitch) + { + Stop_cpu_ccminer_sgminer_nheqminer(willswitch); + } + + public override void Start(string url, string btcAddress, string worker) + { + var apiBind = " --apiport " + ApiPort; + if (MiningSession.DONATION_SESSION) + { + if (url.Contains("zpool.ca")) + { + btcAddress = Globals.DemoUser; + worker = "c=BTC,ID=Donation"; + } + if (url.Contains("ahashpool.com")) + { + btcAddress = Globals.DemoUser; + worker = "c=BTC,ID=Donation"; + + } + if (url.Contains("hashrefinery.com")) + { + btcAddress = Globals.DemoUser; + worker = "c=BTC,ID=Donation"; + + } + if (url.Contains("nicehash.com")) + { + btcAddress = Globals.DemoUser; + worker = "c=BTC,ID=Donation"; + + } + if (url.Contains("zergpool.com")) + { + btcAddress = Globals.DemoUser; + worker = "c=BTC,ID=Donation"; + + } + if (url.Contains("blockmasters.co")) + { + btcAddress = Globals.DemoUser; + worker = "c=BTC,ID=Donation"; + + } + if (url.Contains("blazepool.com")) + { + btcAddress = Globals.DemoUser; + worker = "c=BTC,ID=Donation"; + } + if (url.Contains("miningpoolhub.com")) + { + btcAddress = "cryptominer.Devfee"; + worker = "x"; + } + else + { + btcAddress = Globals.DemoUser; + } + } + else + { + if (url.Contains("zpool.ca")) + { + btcAddress = zPoolMiner.Globals.GetzpoolUser(); + worker = zPoolMiner.Globals.GetzpoolWorker(); + } + if (url.Contains("ahashpool.com")) + { + btcAddress = zPoolMiner.Globals.GetahashUser(); + worker = zPoolMiner.Globals.GetahashWorker(); + + } + if (url.Contains("hashrefinery.com")) + { + btcAddress = zPoolMiner.Globals.GethashrefineryUser(); + worker = zPoolMiner.Globals.GethashrefineryWorker(); + + } + if (url.Contains("nicehash.com")) + { + btcAddress = zPoolMiner.Globals.GetnicehashUser(); + worker = zPoolMiner.Globals.GetnicehashWorker(); + + } + if (url.Contains("zergpool.com")) + { + btcAddress = zPoolMiner.Globals.GetzergUser(); + worker = zPoolMiner.Globals.GetzergWorker(); + + } + if (url.Contains("minemoney.co")) + { + btcAddress = zPoolMiner.Globals.GetminemoneyUser(); + worker = zPoolMiner.Globals.GetminemoneyWorker(); + + } + if (url.Contains("blazepool.com")) + { + btcAddress = zPoolMiner.Globals.GetblazepoolUser(); + worker = zPoolMiner.Globals.GetblazepoolWorker(); + } + if (url.Contains("blockmasters.co")) + { + btcAddress = zPoolMiner.Globals.GetblockmunchUser(); + worker = zPoolMiner.Globals.GetblockmunchWorker(); + } + if (url.Contains("miningpoolhub.com")) + { + btcAddress = zPoolMiner.Globals.GetMPHUser(); + worker = zPoolMiner.Globals.GetMPHWorker(); + } + } + if (!IsInit) + { + Helpers.ConsolePrint(MinerTag(), "MiningSetup is not initialized exiting Start()"); + return; + } + string username = GetUsername(btcAddress, worker); + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.karlsenhash) + LastCommandLine = " --algo KARLSEN" + " --pool=" + url + " --user=" + username + " --pass " + worker + " --devices AMD --watchdog exit"+ apiBind; + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.pyrinhash) + LastCommandLine = " --algo PYRIN" + " --pool=" + url + " --user=" + username + " --pass " + worker + " --devices AMD --watchdog exit" + apiBind; + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.ethash) + LastCommandLine = " --algo ETHASH" + " --pool=" + "stratum+tcp://ethash.mine.zergpool.com:9999" + " --user=" + username + " --pass " + worker + " --devices AMD --watchdog exit" + apiBind; + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.ethashb3) + LastCommandLine = " --algo ETHASHB3" + " --pool=" + "stratum+tcp://ethash.mine.zergpool.com:9996" + " --user=" + username + " --pass " + worker + " --devices AMD --watchdog exit" + apiBind; + + LastCommandLine += GetDevicesCommandString(); + + ProcessHandle = _Start(); + } + + // new decoupled benchmarking routines + #region Decoupled benchmarking routines + + protected override string BenchmarkCreateCommandLine(Algorithm algorithm, int time) + { + var CommandLine = ""; + + string url = Globals.GetLocationURL(algorithm.CryptoMiner937ID, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], this.ConectionType); + string port = url.Substring(url.IndexOf(".com:") + 5, url.Length - url.IndexOf(".com:") - 5); + // demo for benchmark + string username = Globals.GetBitcoinUser(); + + if (ConfigManager.GeneralConfig.WorkerName.Length > 0) + username += ":" + ConfigManager.GeneralConfig.WorkerName.Trim(); + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.karlsenhash) + CommandLine = "--algo KARLSEN --pool " + url + " --user " + "DE8BDPdYu9LadwV4z4KamDqni43BUhGb66 --pass Benchmark " + "--devices AMD --watchdog exit --apihost 127.0.0.1 --apiport " + ApiPort + " --shortstats 120"; + + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.pyrinhash) + CommandLine = "--algo PYRIN --pool " + url + " --user " + "DE8BDPdYu9LadwV4z4KamDqni43BUhGb66 --pass Benchmark " + "--devices AMD --watchdog exit --apihost 127.0.0.1 --apiport " + ApiPort + " --shortstats 120"; + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.ethash) + CommandLine = "--algo ETHASH --pool " + "stratum+tcp://ethash.mine.zergpool.com:9999" + " --user " + "DE8BDPdYu9LadwV4z4KamDqni43BUhGb66 --pass Benchmark " + "--devices AMD --watchdog exit --apihost 127.0.0.1 --apiport " + ApiPort + " --shortstats 120"; + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.ethashb3) + CommandLine = "--algo ETHASHB3 --pool " + "stratum+tcp://ethash.mine.zergpool.com:9996" + " --user " + "DE8BDPdYu9LadwV4z4KamDqni43BUhGb66 --pass Benchmark " + "--devices AMD --watchdog exit --apihost 127.0.0.1 --apiport " + ApiPort + " --shortstats 120"; + + CommandLine += GetDevicesCommandString(); //amd карты перечисляются первыми + + return CommandLine; + + } + + protected override bool BenchmarkParseLine(string outdata) + { + string hashSpeed = ""; + //Average speed (30s): 25.5 sol/s + //GPU 3: Share accepted (45 ms) + if (outdata.Contains("Average speed (120s):")) + { + int i = outdata.IndexOf("Average speed (120s):"); + int k = outdata.IndexOf("Mh/s"); + hashSpeed = outdata.Substring(i + 21, k - i - 22).Trim(); + try + { + speed = speed *1000000 + Double.Parse(hashSpeed, CultureInfo.InvariantCulture); + } + catch + { + MessageBox.Show("Unsupported miner version - " + MiningSetup.MinerPath, + "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + BenchmarkSignalFinnished = true; + return false; + } + count++; + } + + if (outdata.Contains("Share accepted") && speed != 0) + { + BenchmarkAlgorithm.BenchmarkSpeed = speed / count *1000000; + BenchmarkSignalFinnished = true; + return true; + } + + return false; + + } + + + protected override void BenchmarkOutputErrorDataReceivedImpl(string outdata) + { + CheckOutdata(outdata); + } + + + #endregion // Decoupled benchmarking routines + + public class lolResponse + { + public List result { get; set; } + } + + public class lolGpuResult + { + public double sol_ps { get; set; } = 0; + } + // TODO _currentMinerReadStatus + public override async Task GetSummaryAsync() + { + var ad = new APIData(MiningSetup.CurrentAlgorithmType); + string ResponseFromlolMinerNvidia; + try + { + HttpWebRequest WR = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + ApiPort.ToString() + "/summary"); + WR.UserAgent = "GET / HTTP/1.1\r\n\r\n"; + WR.Timeout = 3 * 1000; + WR.Credentials = CredentialCache.DefaultCredentials; + WebResponse Response = WR.GetResponse(); + Stream SS = Response.GetResponseStream(); + SS.ReadTimeout = 2 * 1000; + StreamReader Reader = new StreamReader(SS); + ResponseFromlolMinerNvidia = await Reader.ReadToEndAsync(); + //Helpers.ConsolePrint("API: ", ResponseFromlolMinerNvidia); + //if (ResponseFromlolMiner.Length == 0 || (ResponseFromlolMiner[0] != '{' && ResponseFromlolMiner[0] != '[')) + // throw new Exception("Not JSON!"); + Reader.Close(); + Response.Close(); + } + catch (Exception) + { + return null; + } + + if (ResponseFromlolMinerNvidia == null) + { + CurrentMinerReadStatus = MinerApiReadStatus.NONE; + return null; + } + try + { + dynamic resp = JsonConvert.DeserializeObject(ResponseFromlolMinerNvidia); + int mult = 1; + if (resp != null) + { + int gpus = resp.Session.Active_GPUs; + double totals = resp.Session.Performance_Summary; + if (MiningSetup.CurrentAlgorithmType == AlgorithmType.karlsenhash) + { + mult = 1000000; + } + else + { + mult = 1; + } + ad.Speed = totals * mult; + if (gpus > 0) + { + double[] hashrates = new double[gpus]; + for (var i = 0; i < gpus; i++) + { + hashrates[i] = resp.GPUs[i].Performance; + } + int dev = 0; + var sortedMinerPairs = MiningSetup.MiningPairs.OrderBy(pair => pair.Device.BusID).ToList(); + + + + if (ad.Speed == 0) + { + CurrentMinerReadStatus = MinerApiReadStatus.READ_SPEED_ZERO; + } + else + { + CurrentMinerReadStatus = MinerApiReadStatus.GOT_READ; + } + } + } + } + catch (Exception e) + { + Helpers.ConsolePrint(MinerTag(), e.ToString()); + } + + Thread.Sleep(100); + + //CurrentMinerReadStatus = MinerApiReadStatus.GOT_READ; + // check if speed zero + if (ad.Speed == 0) CurrentMinerReadStatus = MinerApiReadStatus.READ_SPEED_ZERO; + + return ad; + } + } +} diff --git a/zPoolMiner/Miners/Parsing/ExtraLaunchParameters.cs b/zPoolMiner/Miners/Parsing/ExtraLaunchParameters.cs index 8754523..a52fd65 100644 --- a/zPoolMiner/Miners/Parsing/ExtraLaunchParameters.cs +++ b/zPoolMiner/Miners/Parsing/ExtraLaunchParameters.cs @@ -125,7 +125,7 @@ public static class ExtraLaunchParameters } ), new MinerOptionPackage( - MinerType.lolMiner, + MinerType.lolMinerAmd, new List() { // SingleParam new MinerOption("lolMiner_log", "", "--logs", "0", MinerOptionFlagType.SingleParam, ""), diff --git a/zPoolMiner/zPoolMiner.csproj b/zPoolMiner/zPoolMiner.csproj index 4bf6ae3..6770d6a 100644 --- a/zPoolMiner/zPoolMiner.csproj +++ b/zPoolMiner/zPoolMiner.csproj @@ -201,7 +201,7 @@ - + @@ -214,6 +214,7 @@ +