protected override string MiningCreateCommandLine() { // API port function might be blocking _apiPort = GetAvaliablePort(); // instant non blocking var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var split = urlWithPort.Split(':'); var url = split[1].Substring(2, split[1].Length - 2); var port = split[2]; var algo = AlgorithmName(_algorithmType); var commandLine = $"-uri {algo}://{_username}@{url}:{port} -api 127.0.0.1:{_apiPort} {_devices} -watchdog=false {_extraLaunchParameters}"; return(commandLine); }
public virtual string CreateCommandLine(string username) { var urlFirst = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var cmd = ""; if (_algorithmSecondType == AlgorithmType.NONE) //noDual { cmd = $"-di {_devices} -epool {urlFirst} -ewal {username} -esm 3 -epsw x -allpools 1 {_extraLaunchParameters} -wd 0"; } else { var urlSecond = StratumServiceHelpers.GetLocationUrl(_algorithmSecondType, _miningLocation, NhmConectionType.STRATUM_TCP); cmd = $"-di {_devices} -epool {urlFirst} -ewal {username} -esm 3 -epsw x -allpools 1 -dcoin {DualAlgoName} -dpool {urlSecond} -dwal {username} -dpsw x {_extraLaunchParameters} -wd 0"; } return(cmd); }
protected override string MiningCreateCommandLine() { // API port function might be blocking _apiPort = GetAvaliablePort(); // instant non blocking var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var split = urlWithPort.Split(':'); var url = split[1].Substring(2, split[1].Length - 2); var port = split[2]; var algo = AlgorithmName(_algorithmType); //--disablewatchdog 1 var commandLine = $"--coin {algo} --pool {url} --port {port} --user {_username} --tls 0 --apiport {_apiPort} {_disableWatchdogParam} --devices {_devices} {_extraLaunchParameters}"; return(commandLine); }
protected override string MiningCreateCommandLine() { // TODO _miningPairs must not be null or count 0 //if (_miningPairs == null) //throw new NotImplementedException(); // API port function might be blocking _apiPort = GetAvaliablePort(); // instant non blocking var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var algo = AlgorithmName(_algorithmType); var commandLine = $"--algo={algo} --url={url} --user={_username} --api-bind={_apiPort} --devices {_devices} {_extraLaunchParameters}"; return(commandLine); }
public string CreateCommandLine(string username) { var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var deviceType = _miningPairs.FirstOrDefault().Device.DeviceType == DeviceType.AMD ? " -amd" : " -nvidia"; var cmd = $"-pool {urlWithPort} -wal {username} -proto 4 {deviceType} -gpus {_devices} -wdog 0 -gbase 0 {_extraLaunchParameters}"; if (!_extraLaunchParameters.Contains("-stales")) { cmd += " -stales 0"; } if (!_extraLaunchParameters.Contains("-clKernel")) { cmd += " -clKernel 0"; } return(cmd); }
protected override string MiningCreateCommandLine() { // API port function might be blocking _apiPort = GetAvaliablePort(); // instant non blocking var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); if (_algorithmType == AlgorithmType.DaggerHashimoto) { url = $"stratum2+tcp://{StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE)}"; } var algo = AlgorithmName(_algorithmType); var commandLine = $"--algo {algo} --url {url} --user {_username} --api-bind-http 127.0.0.1:{_apiPort} --api-bind-telnet 0 --devices {_devices} {_extraLaunchParameters} --no-watchdog"; return(commandLine); }
private string CreateCommandLine(string username) { _apiPort = GetAvaliablePort(); var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var cmd = ""; //if user wants to manually tweek with config file we let him do that - WARNING some functionalities might not work (benchmarking, api data) if (_extraLaunchParameters.Contains("--config=")) { cmd = _extraLaunchParameters; } else { cmd = $"-a {AlgoName} -o {urlWithPort} -u {username} --http-enabled --http-port={_apiPort} --nicehash {_extraLaunchParameters}"; } Logger.Info("STARTED", $"command: {cmd}"); return(cmd); }
private string CreateCommandLine(string username) { // API port function might be blocking _apiPort = GetAvaliablePort(); var algo = AlgorithmName(_algorithmType); var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var cmd = $"-a {algo} --server {urlWithPort} -u {username} -d {_devices} -w 0 --api {_apiPort} {_extraLaunchParameters}"; if (_algorithmType == AlgorithmType.ZHash) { cmd += " --pers auto"; } return(cmd); }
private string CreateCommandLine(string username) { _apiPort = GetAvaliablePort(); var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); if (_algorithmSecondType == AlgorithmType.NONE) { return($"-a {AlgoName} -o {url} -u {username} --api 127.0.0.1:{_apiPort} {_devices} --no-watchdog {_extraLaunchParameters}"); } var url2 = StratumServiceHelpers.GetLocationUrl(_algorithmSecondType, _miningLocation, NhmConectionType.NONE); var cmd = $"-a {AlgoName} -o {url} -u {username} -do nicehash+tcp://{url2} -du {username} --api 127.0.0.1:{_apiPort} {_devices} --no-watchdog {_extraLaunchParameters}"; if (!_extraLaunchParameters.Contains("--secondary-intensity")) { cmd += " --secondary-intensity 100"; } return(cmd); }
// TODO add cancel token protected async Task <Tuple <bool, IEnumerable <string> > > CreateConfigFiles(IEnumerable <DeviceType> deviceTypes, CancellationToken stop) { //var tag = string.Join("_", _miningPairs.Select(pair => $"{pair.Device.DeviceType.ToString()}_{pair.Device.ID}")); //var genPrefix = $"gen_{_algorithmType.ToString()}_{tag}"; var genPrefix = $"gen_{_algorithmType.ToString()}_{_rand.Next().ToString()}"; var deviceTypeIDs = _miningPairs.Select(pair => Tuple.Create(pair.Device.DeviceType, pair.Device.ID)); var enableDeviceFlagsConfigFiles = CommandLineHelpers.GetConfigCmd(genPrefix, deviceTypeIDs); var enableDeviceTypesStr = string.Join(" ", enableDeviceFlagsConfigFiles.Select(pair => $"{pair.Item1} {pair.Item2}")); var configFlagAndFiles = CommandLineHelpers.GetGeneralAndPoolsConf(genPrefix); var configFlagAndFilesStr = string.Join(" ", configFlagAndFiles); // instant non blocking var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var disableDeviceTypes = CommandLineHelpers.DisableDevCmd(deviceTypes); var currency = AlgorithmName(_algorithmType); var commandLine = $"-o {url} -u {MinerToolkit.DemoUserBTC} --currency {currency} -i 0 --use-nicehash -p x -r x --benchmark 10 --benchwork 60 --benchwait 5 {disableDeviceTypes} {enableDeviceTypesStr} {configFlagAndFilesStr}"; var binPathBinCwdPair = GetBinAndCwdPaths(); var binPath = binPathBinCwdPair.Item1; var binCwd = binPathBinCwdPair.Item2; var envVars = GetEnvironmentVariables(); var configs = enableDeviceFlagsConfigFiles.Select(p => p.Item2); var success = await ConfigHelpers.CreateConfigFiles(configs, binPath, binCwd, commandLine, envVars, stop); var configsFullPath = configs.Select(path => Path.Combine(binCwd, path)); var deleteFiles = Directory.GetFiles(binCwd, "*.*", SearchOption.TopDirectoryOnly).Where(p => p.Contains(genPrefix) && p.Contains("conf")); foreach (var delete in deleteFiles) { try { File.Delete(Path.Combine(binCwd, delete)); } catch (Exception) {} } return(Tuple.Create(success, configsFullPath)); }
private string CreateCommandLine(string username) { // API port function might be blocking _apiPort = GetAvaliablePort(); var algo = AlgorithmName(_algorithmType); var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var split = urlWithPort.Split(':'); var url = split[0]; var port = split[1]; var cmd = $"--par={algo} --server={url} --port={port} --user={username} --cuda-devices={_devices} --telemetry={_apiPort} {_extraLaunchParameters}"; if (_algorithmType == AlgorithmType.ZHash) { cmd += " --pers=auto"; } return(cmd); }
protected override string MiningCreateCommandLine() { // API port function might be blocking _apiPort = GetAvaliablePort(); // instant non blocking var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var algo = AlgorithmName(_algorithmType); var commandLine = $"--pool {urlWithPort} --user {_username} --tls 0 --apiport {_apiPort} {_disableWatchdogParam} --devices {_devices} {_extraLaunchParameters}"; if (_algorithmType == AlgorithmType.ZHash) { commandLine += " --coin AUTO144_5"; } else { commandLine += $" --algo {algo}"; } //--disablewatchdog 1 return(commandLine); }
private string CreateCommandLine(string username) { // API port function might be blocking _apiPort = GetAvaliablePort(); var algo = AlgorithmName(); var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var cmd = $"-a {algo} --proto stratum --server {urlWithPort} -u {username} -d {_devices} -w 0 --api {_apiPort} {_extraLaunchParameters}"; if (_algorithmSecondType != AlgorithmType.NONE) { var urlWithPort2 = StratumServiceHelpers.GetLocationUrl(_algorithmSecondType, _miningLocation, NhmConectionType.NONE); // --algo eth+ckb --server eth.2miners.com:2020 --user 0x5218597d48333d4a70cce91e810007b37e2937b5 --dserver ckb.2miners.com:6464 --duser ckb1qyq9v9yc2pmauycldz4e4ejuxdmvph0xpazq4nh3ph cmd = $"-a {algo} --proto stratum --server {urlWithPort} -u {username} --proto stratum --dserver {urlWithPort2} --duser {username} -d {_devices} -w 0 --api {_apiPort} {_extraLaunchParameters}"; } if (_algorithmType == AlgorithmType.ZHash) { cmd += " --pers auto"; } return(cmd); }
// TODO account AMD kernel building public async override Task <BenchmarkResult> StartBenchmark(CancellationToken stop, BenchmarkPerformanceType benchmarkType = BenchmarkPerformanceType.Standard) { // END prepare config block // determine benchmark time // settup times var openCLCodeGenerationWait = _miningDeviceTypes.Contains(DeviceType.AMD) ? 20 : 0; var benchWait = 5; var benchmarkTime = MinerBenchmarkTimeSettings.ParseBenchmarkTime(new List <int> { 30, 60, 120 }, MinerBenchmarkTimeSettings, _miningPairs, benchmarkType); // in seconds var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var algo = AlgorithmName(_algorithmType); // this one here might block string deviceConfigParams = ""; try { deviceConfigParams = await PrepareDeviceConfigs(stop); } catch (Exception e) { return(new BenchmarkResult { ErrorMessage = e.Message }); } var disableDeviceTypes = CommandLineHelpers.DisableDevCmd(_miningDeviceTypes); var binPathBinCwdPair = GetBinAndCwdPaths(); var binPath = binPathBinCwdPair.Item1; var binCwd = binPathBinCwdPair.Item2; // API port function might be blocking var apiPort = GetAvaliablePort(); var commandLine = $"-o {url} -u {MinerToolkit.DemoUserBTC} --currency {algo} -i {apiPort} --use-nicehash -p x -r x --benchmark 10 --benchwork {benchmarkTime} --benchwait {benchWait} {deviceConfigParams} {disableDeviceTypes}"; Logger.Info(_logGroup, $"Benchmarking started with command: {commandLine}"); var bp = new BenchmarkProcess(binPath, binCwd, commandLine, GetEnvironmentVariables()); var benchHashes = 0d; var benchIters = 0; var benchHashResult = 0d; // Not too sure what this is.. bp.CheckData = (string data) => { var hashrateFoundPair = MinerToolkit.TryGetHashrateAfter(data, "Benchmark Total:"); var hashrate = hashrateFoundPair.Item1; var found = hashrateFoundPair.Item2; if (found) { benchHashes += hashrate; benchIters++; benchHashResult = (benchHashes / benchIters) * (1 - DevFee * 0.01); } return(new BenchmarkResult { AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> { new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult) }, Success = found }); }; // always add 10second extra var benchmarkTimeout = TimeSpan.FromSeconds(10 + (2 * benchmarkTime) + benchWait + openCLCodeGenerationWait); var benchmarkWait = TimeSpan.FromMilliseconds(500); var t = MinerToolkit.WaitBenchmarkResult(bp, benchmarkTimeout, benchmarkWait, stop); return(await t); }
public async override Task <BenchmarkResult> StartBenchmark(CancellationToken stop, BenchmarkPerformanceType benchmarkType = BenchmarkPerformanceType.Standard) { // determine benchmark time // settup times var benchmarkTime = MinerBenchmarkTimeSettings.ParseBenchmarkTime(new List <int> { 40, 60, 120 }, MinerBenchmarkTimeSettings, _miningPairs, benchmarkType); // in seconds var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var algo = AlgorithmName(_algorithmType); var commandLine = $"--algo {algo} --url={urlWithPort} --user {MinerToolkit.DemoUserBTC} --devices {_devices} {_extraLaunchParameters}"; var binPathBinCwdPair = GetBinAndCwdPaths(); var binPath = binPathBinCwdPair.Item1; var binCwd = binPathBinCwdPair.Item2; Logger.Info(_logGroup, $"Benchmarking started with command: {commandLine}"); var bp = new BenchmarkProcess(binPath, binCwd, commandLine, GetEnvironmentVariables()); var benchHashes = 0d; var benchIters = 0; var benchHashResult = 0d; // Not too sure what this is.. var after = $"GPU#"; //if multiple benchmark add gpu cuda id var targetBenchIters = Math.Max(1, (int)Math.Floor(benchmarkTime / 20d)); bp.CheckData = (string data) => { var hasHashRate = data.Contains(after) && data.Contains("-"); if (!hasHashRate) { return new BenchmarkResult { AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> { new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult) }, Success = false } } ; var hashrateFoundPair = data.TryGetHashrateAfter("-"); var hashrate = hashrateFoundPair.Item1; var found = hashrateFoundPair.Item2; if (hashrate == 0 && _algorithmType == AlgorithmType.KAWPOW) { return new BenchmarkResult { AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> { new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult) }, Success = false } } ; benchHashes += hashrate; benchIters++; benchHashResult = (benchHashes / benchIters) * (1 - DevFee * 0.01); return(new BenchmarkResult { AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> { new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult) }, Success = benchIters >= targetBenchIters }); }; var benchmarkTimeout = TimeSpan.FromSeconds(benchmarkTime + 10); var benchmarkWait = TimeSpan.FromMilliseconds(500); var t = MinerToolkit.WaitBenchmarkResult(bp, benchmarkTimeout, benchmarkWait, stop); return(await t); }