Ejemplo n.º 1
0
        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 = PluginSupportedAlgorithms.AlgorithmName(_algorithmType);

            var commandLine = $"--algo={algo} --url={url} --user={username} --api-bind={_apiPort} {_extraLaunchParameters}";

            return(commandLine);
        }
Ejemplo n.º 2
0
        public override Dictionary <BaseDevice, IReadOnlyList <Algorithm> > GetSupportedAlgorithms(IEnumerable <BaseDevice> devices)
        {
            // TODO set is intel/amd
            var cpus = devices.Where(dev => dev is CPUDevice).Cast <CPUDevice>();

            IsIntel = IsIntelCpu(cpus);
            var supported = new Dictionary <BaseDevice, IReadOnlyList <Algorithm> >();

            foreach (var cpu in cpus)
            {
                supported.Add(cpu, PluginSupportedAlgorithms.GetSupportedAlgorithmsCPU(PluginUUID));
            }

            return(supported);
        }
Ejemplo n.º 3
0
 public CPUMinerPlugin()
 {
     // set default internal settings
     MinerOptionsPackage    = PluginInternalSettings.MinerOptionsPackage;
     GetApiMaxTimeoutConfig = PluginInternalSettings.GetApiMaxTimeoutConfig;
     DefaultTimeout         = PluginInternalSettings.DefaultTimeout;
     // https://bitcointalk.org/index.php?topic=1326803.0 | https://github.com/JayDDee/cpuminer-opt/releases
     MinersBinsUrlsSettings = new MinersBinsUrlsSettings
     {
         BinVersion = "v3.9.9.1",
         ExePath    = new List <string> {
             "cpuminer-avx2.exe"
         },                                                  // special case multiple executables
         Urls = new List <string>
         {
             "https://github.com/JayDDee/cpuminer-opt/releases/download/v3.9.9.1/cpuminer-opt-3.9.9.1-windows.zip", // original
         }
     };
     PluginMetaInfo = new PluginMetaInfo
     {
         PluginDescription          = "Miner for CPU devices.",
         SupportedDevicesAlgorithms = PluginSupportedAlgorithms.SupportedDevicesAlgorithmsDict()
     };
 }
Ejemplo n.º 4
0
        public async override Task <BenchmarkResult> StartBenchmark(CancellationToken stop, BenchmarkPerformanceType benchmarkType = BenchmarkPerformanceType.Standard)
        {
            var benchmarkTime = MinerPluginToolkitV1.Configs.MinerBenchmarkTimeSettings.ParseBenchmarkTime(new List <int> {
                20, 60, 120
            }, MinerBenchmarkTimeSettings, _miningPairs, benchmarkType);                                                                                                                            // in seconds

            var algo        = PluginSupportedAlgorithms.AlgorithmName(_algorithmType);
            var commandLine = $"--algo={algo} --benchmark --time-limit {benchmarkTime} {_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());

            double benchHashesSum  = 0;
            double benchHashResult = 0;
            int    benchIters      = 0;
            var    foundBench      = false;

            bp.CheckData = (string data) => {
                if (!data.Contains("Total:"))
                {
                    return new BenchmarkResult {
                               AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> {
                                   new AlgorithmTypeSpeedPair(_algorithmType, 0)
                               }, Success = false
                    }
                }
                ;
                var hashrateFoundPairAvg = MinerToolkit.TryGetHashrateAfter(data, "H, ");
                var hashrateAvg          = hashrateFoundPairAvg.Item1;
                var foundAvg             = hashrateFoundPairAvg.Item2;
                if (!foundAvg)
                {
                    var hashrateFoundPair = MinerToolkit.TryGetHashrateAfter(data, "Benchmark: ");

                    var hashrate = hashrateFoundPair.Item1;
                    foundBench = hashrateFoundPair.Item2;
                    if (foundBench && hashrate != 0)
                    {
                        benchHashResult = hashrate * (1 - DevFee * 0.01);

                        return(new BenchmarkResult
                        {
                            AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> {
                                new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult)
                            },
                            Success = benchHashResult != 0
                        });
                    }
                }

                // sum and return
                benchHashesSum += hashrateAvg;
                benchIters++;

                benchHashResult = (benchHashesSum / benchIters) * (1 - DevFee * 0.01);

                return(new BenchmarkResult
                {
                    AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> {
                        new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult)
                    },
                    Success = foundBench
                });
            };

            var benchmarkTimeout = TimeSpan.FromSeconds(benchmarkTime + 5);
            var benchmarkWait    = TimeSpan.FromMilliseconds(500);
            var t = MinerToolkit.WaitBenchmarkResult(bp, benchmarkTimeout, benchmarkWait, stop);

            return(await t);
        }