protected override string MiningCreateCommandLine() { // API port function might be blocking _apiPort = GetAvaliablePort(); // instant non blocking var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var binPathBinCwdPair = GetBinAndCwdPaths(); var binCwd = binPathBinCwdPair.Item2; var algo = AlgorithmName(_algorithmType); // prepare configs var folder = _algorithmType.ToString().ToLower(); // run in new task so we don't deadlock main thread var deviceConfigParams = Task.Run(() => PrepareDeviceConfigs(CancellationToken.None)).Result; var generalConfigFilePath = Path.Combine(binCwd, folder, "config.txt"); var generalConfig = new MainConfig { httpd_port = _apiPort }; ConfigHelpers.WriteConfigFile(generalConfigFilePath, generalConfig); var poolsConfigFilePath = Path.Combine(binCwd, folder, "pools.txt"); var poolsConfig = new PoolsConfig(urlWithPort, _username, algo); ConfigHelpers.WriteConfigFile(poolsConfigFilePath, poolsConfig); var disableDeviceTypes = CommandLineHelpers.DisableDevCmd(_miningDeviceTypes); var commandLine = $@"--config {folder}\config.txt --poolconf {folder}\pools.txt {deviceConfigParams} {disableDeviceTypes} {_extraLaunchParameters}"; 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"; } if (!_extraLaunchParameters.Contains("--dual_intensity") && _algorithmSecondType == AlgorithmType.Eaglesong) { _extraLaunchParameters += " --dual_intensity 0"; } return(cmd); }
private string CreateCommandLine(string username) { _apiPort = GetAvaliablePort(); var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); return($"-a {AlgoName} -o {url} -u {username} --api-port={_apiPort} -d {_devices} --multiple-instance {_extraLaunchParameters}"); }
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 algorithmParam = $"--algo {algo}"; if (_algorithmType == AlgorithmType.ZHash) { algorithmParam += " --pers auto"; } var ret = $"{algorithmParam} --cuda_devices {_devices} --user {username} --server {url} --port {port} --pass x --api 127.0.0.1:{_apiPort} {_extraLaunchParameters}"; if (!ret.Contains("--fee")) { ret += " --fee 0"; DevFee = 0.0d; } return(ret); }
protected virtual string MiningCreateCommandLine() { var(oclPlatform, oclPlatformOk) = MinerToolkit.GetOpenCLPlatformID(_miningPairs); _apiPort = GetAvaliablePort(); var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var(url1, port1, _) = SplitUrlWithPort(urlWithPort); var url2WithPort = StratumServiceHelpers.GetLocationUrl(_algorithmSecondType, _miningLocation, NhmConectionType.NONE); var(url2, port2, _) = SplitUrlWithPort(url2WithPort); var name = string.Join("+", _miningPairs.First().Algorithm.IDs.Select(a => $"{a}")); var ssl = MinerToolkit.EnableSSLMining; var(template, correctTemplate) = MinerCommandLineSettings.GetCommandLineTemplate(name, MinerCommandLineSettings, ssl); if (!correctTemplate) { Logger.Warn(_logGroup, $"MiningCreateCommandLine {name} got wrong template SSL='{ssl}'"); } var args = new MinerCommandLineSettings.CommandLineParams { Username = _username, ApiPort = $"{_apiPort}", Url = url1, Port = port1, Url2 = url2, Port2 = port2, Devices = _devices, OpenClAmdPlatformNum = $"{oclPlatform}", ExtraLaunchParameters = _extraLaunchParameters, }; return(MinerCommandLineSettings.MiningCreateCommandLine(template, args)); }
private string CreateCommandLine(string username) { _apiPort = GetAvaliablePort(); var algo = AlgorithmName(_algorithmType); var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var paths = GetBinAndCwdPaths(); var configString = ""; if (_extraLaunchParameters != "") { var arrayOfELP = _extraLaunchParameters.Split(' '); foreach (var elp in arrayOfELP) { configString += $"{elp}\r\n"; } } var devs = string.Join(",", _miningPairs.Select(p => _mappedIDs[p.Device.UUID])); configString += $"webPort={_apiPort}\r\nwatchdog=false\n\r\n\r[{algo}]\r\nwallet={username}\r\nrigName=\r\ndevices={devs}\r\npool1={url}"; try { File.WriteAllText(Path.Combine(paths.Item2, $"config_nh_{devs}.ini"), configString); } catch (Exception e) { Logger.Error(_logGroup, $"Unable to create config file: {e.Message}"); } return($"config_nh_{devs}.ini"); }
protected string CreateCommandLine(string username) { var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var cmd = $"-k {AlgoName} -o {url} -u {username} -p x {_extraLaunchParameters} {_devicesOnPlatform}"; return(cmd); }
private string CreateCommandLine(string username) { _apiPort = GetAvaliablePort(); var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); // NVIDIA only platform return($"-a {AlgoName} -o {url} -u {username} --api 127.0.0.1:{_apiPort} {_devices} --no-watchdog --platform 1 {_extraLaunchParameters}"); }
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}"; return(cmd); }
private string CreateCommandLine(string username) { _apiPort = GetAvaliablePort(); var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var cmd = $"-a {AlgoName} -url {url} -u {username} -d {_devices} --api-bind 127.0.0.1:{_apiPort} {_extraLaunchParameters}"; return(cmd); }
private string CreateCommandLine(string username) { _apiPort = GetAvaliablePort(); var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var devs = string.Join(",", _miningPairs.Select(p => _mappedIDs[p.Device.UUID])); return($"-a {AlgoName} -o {url} -u {username} --api 127.0.0.1:{_apiPort} -d {devs} -RUN {_extraLaunchParameters}"); }
protected override string MiningCreateCommandLine() { // API port function might be blocking _apiPort = GetAvaliablePort(); var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); var cmd = $"--algorithm {AlgoName} --pool {urlWithPort} --wallet {_username} --gpu-id {_devices} --disable-cpu --api-enable --api-port {_apiPort} {_extraLaunchParameters}"; return(cmd); }
public async override Task <BenchmarkResult> StartBenchmark(CancellationToken stop, BenchmarkPerformanceType benchmarkType = BenchmarkPerformanceType.Standard) { // determine benchmark time // settup times var benchmarkTime = MinerBenchmarkTimeSettings.ParseBenchmarkTime(new List <int> { 30, 60, 120 }, MinerBenchmarkTimeSettings, _miningPairs, benchmarkType); // in seconds 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} {_devices} -watchdog=false {_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 targetBenchIters = Math.Max(1, (int)Math.Floor(benchmarkTime / 20d)); bp.CheckData = (string data) => { var hashrateFoundPair = MinerToolkit.TryGetHashrateAfter(data, "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 = benchIters >= targetBenchIters }); }; var benchmarkTimeout = TimeSpan.FromSeconds(benchmarkTime + 10); var benchmarkWait = TimeSpan.FromMilliseconds(500); var t = MinerToolkit.WaitBenchmarkResult(bp, benchmarkTimeout, benchmarkWait, stop); return(await t); }
protected override string MiningCreateCommandLine() { // API port function might be blocking _apiPort = GetAvaliablePort(); // instant non blocking var urlWithPort = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); var poolWithUsername = $"stratum2+tcp://{_username}@{urlWithPort}"; // TODO add readonly API port var commandLine = $"--pool {poolWithUsername} --api-bind 127.0.0.1:{_apiPort} {_cudaDevices} {_openCLDevices} {_extraLaunchParameters}"; return(commandLine); }
protected override string MiningCreateCommandLine() { // 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} -b 127.0.0.1:{_apiPort} --device {_devices} --no-watchdog {_extraLaunchParameters}"; return(commandLine); }
private string CreateCommandLine(string username) { // 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} {_extraLaunchParameters}"; return(commandLine); }
private string CreateCommandLine(string username) { // API port function might be blocking _apiPort = GetAvaliablePort(); 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 cmd = $"--ccryptonighttype {AlgoName} --cpool {url}:{port} --cwallet {username} --cgpuid {_devices} --cnicehash true --disablegpuwatchdog --apienable --apiport {_apiPort} {_extraLaunchParameters}"; 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); return($"-a {AlgoName} -o {url} -u {username} -do nicehash+tcp://{url2} -du {username} --api 127.0.0.1:{_apiPort} {_devices} --no-watchdog {_extraLaunchParameters}"); }
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); //--disablewatchdog 1 var commandLine = $"--algo {algo} --pool {urlWithPort} --user {_username} --tls 0 --apiport {_apiPort} {_disableWatchdogParam} --devices {_devices} {_extraLaunchParameters}"; return(commandLine); }
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() { // 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); }
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() { // 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) { // 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 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); }
// 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); }
private string CreateCommandLine(string username) { _apiPort = GetAvaliablePort(); var url = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.STRATUM_TCP); if (_algorithmSecondType == AlgorithmType.NONE && _algorithmType != AlgorithmType.DaggerHashimoto) { return($"-a {AlgoName} -o {url} -u {username} --api 127.0.0.1:{_apiPort} {_devices} --no-watchdog {_extraLaunchParameters}"); } if (_algorithmSecondType == AlgorithmType.NONE && _algorithmType == AlgorithmType.DaggerHashimoto) { var url_dagger = StratumServiceHelpers.GetLocationUrl(_algorithmType, _miningLocation, NhmConectionType.NONE); return($"-a {AlgoName} -o nicehash+tcp://{url_dagger} -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 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); }