Ejemplo n.º 1
0
        // TODO this can be moved in MinerApiWatchdog
        private void UpdateApiTimestamp(ApiData apiData)
        {
            // we will not update api timestamps if we have no data or speeds are zero
            if (apiData == null)
            {
                // TODO debug log no api data
                return;
            }
            if (apiData.AlgorithmSpeedsTotal == null && apiData.AlgorithmSpeedsPerDevice == null)
            {
                // TODO debug log cannot get speeds
                return;
            }
            var speedsTotalSum       = apiData.AlgorithmSpeedsTotal?.Select(p => p.Speed).Sum() ?? 0d;
            var perDevSpeedsTotalSum = apiData.AlgorithmSpeedsPerDevice?.Values.SelectMany(pl => pl).Select(p => p.Speed).Sum() ?? 0d;

            if (speedsTotalSum == 0d && perDevSpeedsTotalSum == 0d)
            {
                // TODO debug log speeds are zero
                return;
            }
            if (speedsTotalSum == _lastSpeedsTotalSum && perDevSpeedsTotalSum == _lastPerDevSpeedsTotalSum)
            {
                // TODO debug log speeds seem to be stuck
                return;
            }
            // update
            _lastSpeedsTotalSum       = speedsTotalSum;
            _lastPerDevSpeedsTotalSum = perDevSpeedsTotalSum;
            MinerApiWatchdog.UpdateApiTimestamp(GroupKey, DateTime.UtcNow);
        }
Ejemplo n.º 2
0
        private static async Task RestartStagnatedMiners()
        {
            var restartGroups = MinerApiWatchdog.GetTimedoutGroups(DateTime.UtcNow);

            if (restartGroups == null)
            {
                return;
            }
            await _semaphore.WaitAsync();

            try
            {
                var miningLocation = StratumService.SelectedServiceLocation;
                foreach (var groupKey in restartGroups)
                {
                    if (_runningMiners.ContainsKey(groupKey) == false)
                    {
                        continue;
                    }

                    Logger.Info(Tag, $"Restarting miner group='{groupKey}' API timestamp exceeded");
                    await _runningMiners[groupKey].StopTask();
                    await _runningMiners[groupKey].StartTask(miningLocation, _username);
                }
            }
            finally
            {
                _semaphore.Release();
            }
        }
Ejemplo n.º 3
0
        private async Task <object> StartAsync(CancellationToken stop, string miningLocation, string username)
        {
            _miner.InitMiningLocationAndUsername(miningLocation, username);
            _miner.InitMiningPairs(_miningPairs);
            EthlargementIntegratedPlugin.Instance.Start(_miningPairs);
            var ret = await _miner.StartMiningTask(stop);

            var maxTimeout = _plugin.GetApiMaxTimeout(_miningPairs);

            MinerApiWatchdog.AddGroup(GroupKey, maxTimeout, DateTime.UtcNow);
            _algos.ForEach(a => a.IsCurrentlyMining = true);
            return(ret);
        }
Ejemplo n.º 4
0
 public void Stop()
 {
     // TODO thing about this case, closing opening on switching
     // EthlargementIntegratedPlugin.Instance.Stop(_miningPairs);
     MinerApiWatchdog.RemoveGroup(GroupKey);
     MiningStats.RemoveGroup(MiningPairs.Select(pair => pair.Device.UUID), _plugin.PluginUUID);
     IsRunning = false;
     _miner.StopMining();
     //if (_miner is IDisposable disposableMiner)
     //{
     //    disposableMiner.Dispose();
     //}
 }
Ejemplo n.º 5
0
        private async Task StopAsync()
        {
            // TODO thing about this case, closing opening on switching
            EthlargementIntegratedPlugin.Instance.Stop(_miningPairs);
            MinerApiWatchdog.RemoveGroup(GroupKey);
            MiningDataStats.RemoveGroup(_miningPairs.Select(pair => pair.Device.UUID), _plugin.PluginUUID);
            await _miner.StopMiningTask();

            _algos.ForEach(a => a.IsCurrentlyMining = false);
            //if (_miner is IDisposable disposableMiner)
            //{
            //    disposableMiner.Dispose();
            //}
        }
Ejemplo n.º 6
0
        private async Task <object> StartAsync(CancellationToken stop, string username)
        {
            _miner.InitMiningLocationAndUsername("auto", username);
            _miner.InitMiningPairs(_miningPairs);
            GPUProfileManager.Instance.Start(_miningPairs);
            var ret = await _miner.StartMiningTask(stop);

            var maxTimeout = _plugin.GetApiMaxTimeout(_miningPairs);

            MinerApiWatchdog.AddGroup(GroupKey, maxTimeout, DateTime.UtcNow);
            _algos.ForEach(a => a.IsCurrentlyMining   = true);
            _algos.ForEach(a => a.ComputeDevice.State = DeviceState.Mining);
            return(ret);
        }
Ejemplo n.º 7
0
        // TODO this thing
        public void Start(string miningLocation, string username)
        {
            if (_isEnded)
            {
                return;
            }
            _miner.InitMiningLocationAndUsername(miningLocation, username);
            _miner.InitMiningPairs(MiningPairs);
            EthlargementIntegratedPlugin.Instance.Start(MiningPairs);
            _miner.StartMining();
            IsRunning = true;
            // maxTimeout = ConfigManager.GeneralConfig.CoolDownCheckEnabled
            var maxTimeout = _plugin.GetApiMaxTimeout(MiningPairs);

            MinerApiWatchdog.AddGroup(GroupKey, maxTimeout, DateTime.UtcNow);
        }