Exemple #1
0
        public override void Run(CancellationToken internCtx, CancellationToken externCtx)
        {
            try
            {
                var parameter = $"--farm-recheck 200 -S {_ip}:{_port} -u {RewardCoin}:{RewardAddress} ";

                if (MiningHardware.FirstOrDefault()?.Type == HardwareType.Cuda)
                {
                    parameter += $"-U --cuda-devices {string.Join(" ", MiningHardware.Select(i => i.Index))}";
                }
                else if (MiningHardware.FirstOrDefault()?.Type == HardwareType.OpenCl)
                {
                    parameter += $"-G --opencl-platform {string.Join(" ", MiningHardware.Select(i => i.PlatformIndex))} " +
                                 $"--opencl-devices {string.Join(" ", MiningHardware.Select(i => i.Index))}";
                }

                Logger.Debug($"Starting {Miner.Path} {parameter}");

                Task.Run(() =>
                {
                    while (!internCtx.IsCancellationRequested)
                    {
                        if (externCtx.IsCancellationRequested)
                        {
                            Cancel();
                        }
                        else
                        {
                            externCtx.WaitHandle.WaitOne(1000);
                        }
                    }
                }, internCtx);

                foreach (var line in ProcessHelper.ReadLines(Miner.Path, parameter, internCtx))
                {
                    Logger.Info(line);
                }
            }
            catch (OperationCanceledException e)
            {
                if (e.CancellationToken.IsCancellationRequested)
                {
                    e.CancellationToken.ThrowIfCancellationRequested();
                }
            }
        }
Exemple #2
0
        public override void Run(CancellationToken internCtx, CancellationToken externCtx)
        {
            try
            {
                var uri       = $"stratum+tcp://{_ip}:{_port}";
                var parameter = $"-o {uri} -d {string.Join(",", MiningHardware.Select(i => i.Index))} -a {Algorithm} --no-color " +
                                $"-u {RewardCoin}:{RewardAddress}";
                Logger.Debug($"Starting {Miner.Path} {parameter}");

                Task.Run(() =>
                {
                    while (!internCtx.IsCancellationRequested)
                    {
                        if (externCtx.IsCancellationRequested)
                        {
                            Cancel();
                        }
                        else
                        {
                            externCtx.WaitHandle.WaitOne(1000);
                        }
                    }
                }, internCtx);

                foreach (var line in ProcessHelper.ReadLines(Miner.Path, parameter, internCtx))
                {
                    var rgx = Regex.Match(line, @"\[.*\]\s*(.*)");
                    Logger.Info(rgx.Groups[1].Value);
                }
            }
            catch (OperationCanceledException e)
            {
                if (e.CancellationToken.IsCancellationRequested)
                {
                    e.CancellationToken.ThrowIfCancellationRequested();
                }
            }
        }