public static (bool started, string failReason) StartDevice(ComputeDevice device, bool skipBenhcmakrk = false) { // we can only start a device it is already stopped if (device.State != DeviceState.Stopped && !skipBenhcmakrk) { return(false, "Device already started"); } var started = true; var failReason = ""; var isErrorState = !device.AnyAlgorithmEnabled(); var isAllZeroPayingState = device.AllEnabledAlgorithmsZeroPaying(); // check if device has any benchmakrs var needsBenchmark = device.AllEnabledAlgorithmsWithoutBenchmarks(); var needsReBenchmark = device.HasEnabledAlgorithmsWithReBenchmark(); if (isErrorState || isAllZeroPayingState) { device.State = DeviceState.Error; started = false; failReason = isAllZeroPayingState ? "No enabled algorithm is profitable" : "Cannot start a device with all disabled algoirhtms"; } else if (needsBenchmark && !skipBenhcmakrk) { device.State = DeviceState.Benchmarking; BenchmarkManager.StartBenchmarForDevice(device, new BenchmarkStartSettings { StartMiningAfterBenchmark = true, BenchmarkPerformanceType = BenchmarkPerformanceType.Standard, BenchmarkOption = BenchmarkOption.ZeroOnly }); } else if (needsReBenchmark && !skipBenhcmakrk) { device.State = DeviceState.Benchmarking; BenchmarkManager.StartBenchmarForDevice(device, new BenchmarkStartSettings { StartMiningAfterBenchmark = true, BenchmarkPerformanceType = BenchmarkPerformanceType.Standard, BenchmarkOption = BenchmarkOption.ReBecnhOnly }); } else { device.State = DeviceState.Mining; UpdateDevicesToMine(); } RefreshDeviceListView?.Invoke(null, null); NiceHashStats.StateChanged(); return(started, failReason); }