Exemplo n.º 1
0
        public List <Algorithm> GetAlgorithmSettings()
        {
            // hello state
            var algos = GetAlgorithmSettingsThirdParty(ConfigManager.GeneralConfig.Use3rdPartyMiners);

            var retAlgos = MinerPaths.GetAndInitAlgorithmsMinerPaths(algos, this);;

            // additional filters
            // CPU
            if (this.DeviceType == DeviceType.CPU && MinersManager.EquihashCPU_USE_eqm())
            {
                retAlgos = retAlgos.FindAll((a) => a.MinerBaseType != MinerBaseType.nheqminer);
            }
            else if (this.DeviceType == DeviceType.CPU)
            {
                retAlgos = retAlgos.FindAll((a) => a.MinerBaseType != MinerBaseType.eqm);
            }
            // NVIDIA
            if (this.DeviceGroupType == DeviceGroupType.NVIDIA_5_x || this.DeviceGroupType == DeviceGroupType.NVIDIA_6_x)
            {
                retAlgos = retAlgos.FindAll((a) => a.MinerBaseType != MinerBaseType.nheqminer);
            }
            else if (this.DeviceType == DeviceType.NVIDIA)
            {
                retAlgos = retAlgos.FindAll((a) => a.MinerBaseType != MinerBaseType.eqm);
            }

            // sort by miner and algo
            //retAlgos.Sort((a_1, a_2) => (a_1.MinerBaseType - a_2.MinerBaseType) != 0 ? (a_1.MinerBaseType - a_2.MinerBaseType) : (a_1.NiceHashID - a_2.NiceHashID));
            // sort by algo
            retAlgos.Sort((a_1, a_2) => (a_1.NiceHashID - a_2.NiceHashID) != 0 ? (a_1.NiceHashID - a_2.NiceHashID) : (a_1.MinerBaseType - a_2.MinerBaseType));

            return(retAlgos);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The DeviceStatus_Tick
        /// </summary>
        /// <param name="state">The <see cref="object"/></param>
        public static void DeviceStatus_Tick(object state)
        {
            var devices    = ComputeDeviceManager.Avaliable.AllAvaliableDevices;
            var deviceList = new List <JArray>();
            var activeIDs  = MinersManager.GetActiveMinersIndexes();

            foreach (var device in devices)
            {
                try
                {
                    var array = new JArray
                    {
                        device.Index,
                        device.Name
                    };
                    int status = Convert.ToInt32(activeIDs.Contains(device.Index)) + (((int)device.DeviceType + 1) * 2);
                    array.Add(status);
                    array.Add((uint)device.Load);
                    array.Add((uint)device.Temp);
                    array.Add((uint)device.FanSpeed);

                    deviceList.Add(array);
                }
                catch (Exception e) { Helpers.ConsolePrint("SOCKET", e.ToString()); }
            }
            var data = new Nicehash_device_status
            {
                devices = deviceList
            };
            var sendData = JsonConvert.SerializeObject(data);
        }
        private void UpdateGlobalRate()
        {
            var totalRate = MinersManager.GetTotalRate();

            if (ConfigManager.GeneralConfig.AutoScaleBTCValues && totalRate < 0.1)
            {
                toolStripStatusLabelBTCDayText.Text =
                    "mBTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString());
                toolStripStatusLabelGlobalRateValue.Text =
                    (totalRate * 1000 * _factorTimeUnit).ToString("F5", CultureInfo.InvariantCulture);
            }
            else
            {
                toolStripStatusLabelBTCDayText.Text =
                    "BTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString());
                toolStripStatusLabelGlobalRateValue.Text =
                    (totalRate * _factorTimeUnit).ToString("F6", CultureInfo.InvariantCulture);
            }

            toolStripStatusLabelBTCDayValue.Text = ExchangeRateApi
                                                   .ConvertToActiveCurrency((totalRate * _factorTimeUnit * ExchangeRateApi.GetUsdExchangeRate()))
                                                   .ToString("F2", CultureInfo.InvariantCulture);
            toolStripStatusLabelBalanceText.Text = (ExchangeRateApi.ActiveDisplayCurrency + "/") +
                                                   International.GetText(
                ConfigManager.GeneralConfig.TimeUnit.ToString()) + "     " +
                                                   International.GetText("Form_Main_balance") + ":";
        }
Exemplo n.º 4
0
        private void StopMining()
        {
            MinerStatsCheck.Stop();
            SMAMinerCheck.Stop();

            MinersManager.StopAllMiners();

            textBoxBTCAddress.Enabled = true;
            textBoxWorkerName.Enabled = true;
            comboBoxLocation.Enabled  = true;
            buttonBenchmark.Enabled   = true;
            buttonStartMining.Enabled = true;
            buttonSettings.Enabled    = true;
            devicesListViewEnableControl1.IsMining = false;
            buttonStopMining.Enabled = false;

            if (DemoMode)
            {
                DemoMode = false;
                labelDemoMode.Visible = false;
            }
            if (ConfigManager.GeneralConfig.WebInterfaceEnabled)
            {
                File.WriteAllText(Path.Combine(((DriveDirectory)server.Root).Path, "stats.json"), "[ { \"Status\": \"Nicehash Miner is stopped\" } ]");
            }
            server.Stop();
            UpdateGlobalRate();
        }
Exemplo n.º 5
0
        private void StopMining()
        {
            MinerStatsCheck.Stop();
            SMAMinerCheck.Stop();

            // Disable IFTTT notification before label call
            IsNotProfitable = false;

            MinersManager.StopAllMiners();

            textBoxBTCAddress.Enabled = true;
            textBoxWorkerName.Enabled = true;
            comboBoxLocation.Enabled  = true;
            buttonBenchmark.Enabled   = true;
            buttonStartMining.Enabled = true;
            buttonSettings.Enabled    = true;
            devicesListViewEnableControl1.IsMining = false;
            buttonStopMining.Enabled = false;

            if (DemoMode)
            {
                DemoMode = false;
                labelDemoMode.Visible = false;
            }

            UpdateGlobalRate();
        }
Exemplo n.º 6
0
        public static void DeviceStatus_Tick(object state)
        {
            var devices    = ComputeDeviceManager.Avaliable.AllAvaliableDevices;
            var deviceList = new List <JArray>();
            var activeIDs  = MinersManager.GetActiveMinersIndexes();

            foreach (var device in devices)
            {
                try
                {
                    var array = new JArray
                    {
                        device.Index,
                        device.Name
                    };
                    int status = Convert.ToInt32(activeIDs.Contains(device.Index)) + (((int)device.DeviceType + 1) * 2);
                    array.Add(status);
                    array.Add((uint)device.Load);
                    array.Add((uint)device.Temp);
                    array.Add((uint)device.FanSpeed);

                    deviceList.Add(array);
                }
                catch (Exception e) { Helpers.ConsolePrint("SOCKET", e.ToString()); }
            }
            var data = new Nicehash_device_status
            {
                devices = deviceList
            };
            var sendData = JsonConvert.SerializeObject(data);
            // This function is run every minute and sends data every run which has two auxiliary effects
            // Keeps connection alive and attempts reconnection if internet was dropped
            //NiceHashConnection.SendData(sendData);
        }
Exemplo n.º 7
0
        //private string _miningLocation = "";
        //private string _btcAdress = "";
        //private string _worker = "";

        // , string miningLocation, string btcAdress, string worker
        public GroupMiner(List <MiningPair> miningPairs, string key)
        {
            AlgorithmType     = AlgorithmType.NONE;
            DevicesInfoString = "N/A";
            CurrentRate       = 0;
            Key = key;
            if (miningPairs.Count > 0)
            {
                // sort pairs by device id
                miningPairs.Sort((a, b) => a.Device.ID - b.Device.ID);
                // init name scope
                {
                    List <string> deviceNames = new List <string>();
                    foreach (var pair in miningPairs)
                    {
                        deviceNames.Add(pair.Device.NameCount);
                    }
                    DevicesInfoString = "{ " + string.Join(", ", deviceNames) + " }";
                }
                // init miner
                {
                    var mPair = miningPairs[0];
                    DeviceType = mPair.Device.DeviceType;
                    Miner      = MinersManager.CreateMiner(mPair.Device.DeviceType,
                                                           MinerPaths.GetOptimizedMinerPath(mPair));
                    if (Miner != null)
                    {
                        Miner.InitMiningSetup(new MiningSetup(miningPairs));
                        AlgorithmType = mPair.Algorithm.NiceHashID;
                    }
                }
            }
        }
 public override async Task OnConnectedAsync()
 {
     MinersManager.AddMiner(this.XUser, this.XWorker);
     if (MinersManager.LastJob != null)
     {
         await this.Clients.Caller.SendAsync("NewJob", MinersManager.LastJob);
     }
     await base.OnConnectedAsync();
 }
Exemplo n.º 9
0
        public IActionResult DashboardJson()
        {
            var result = new DashboardModel();

            result.TopMiners = MinersManager.GetTopMiners();
            result.Report    = MinersManager.GetReport();
            result.MinedJobs = MinersManager.GetLastMinedJobs();
            return(this.Json(result));
        }
Exemplo n.º 10
0
        public static string GetOptimizedMinerPath(AlgorithmType algorithmType, DeviceType deviceType, DeviceGroupType deviceGroupType, string devCodename, bool isOptimized)
        {
            // special cases
            // AlgorithmType.DaggerHashimoto special shared case
            if (algorithmType == AlgorithmType.DaggerHashimoto &&
                (deviceType == DeviceType.AMD || deviceType == DeviceType.NVIDIA))
            {
                return(MinerPaths.ethminer);
            }
            // AlgorithmType.Equihash special shared case
            if (algorithmType == AlgorithmType.Equihash)
            {
                if (deviceGroupType == DeviceGroupType.NVIDIA_5_x || deviceGroupType == DeviceGroupType.NVIDIA_6_x ||
                    (MinersManager.EquihashCPU_USE_eqm() && DeviceGroupType.CPU == deviceGroupType))
                {
                    return(MinerPaths.eqm);
                }
                else if (deviceType == DeviceType.AMD && ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES)    // TODO remove state
                {
                    return(MinerPaths.ClaymoreZcashMiner);
                }
                else   // supports all DeviceTypes
                {
                    return(MinerPaths.nheqminer);
                }
            }
            // normal stuff
            // CPU
            if (deviceType == DeviceType.CPU)
            {
                return(CPU_GROUP.cpu_miner_opt(CPUUtils.GetMostOptimized()));
            }
            // NVIDIA
            if (deviceType == DeviceType.NVIDIA)
            {
                var nvidiaGroup = deviceGroupType;
                // sm21 and sm3x have same settings
                if (nvidiaGroup == DeviceGroupType.NVIDIA_2_1 || nvidiaGroup == DeviceGroupType.NVIDIA_3_x)
                {
                    return(NVIDIA_GROUPS.ccminer_sm21_or_sm3x(algorithmType));
                }
                // sm5x and sm6x have same settings
                if (nvidiaGroup == DeviceGroupType.NVIDIA_5_x || nvidiaGroup == DeviceGroupType.NVIDIA_6_x)
                {
                    return(NVIDIA_GROUPS.ccminer_sm5x_or_sm6x(algorithmType));
                }
            }
            // AMD
            if (deviceType == DeviceType.AMD)
            {
                return(AMD_GROUP.sgminer_path(algorithmType, devCodename, isOptimized));
            }

            return(NONE);
        }
Exemplo n.º 11
0
        private void SMAMinerCheck_Tick(object sender, EventArgs e)
        {
            SMAMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000);
            if (ComputeDeviceManager.Group.ContainsAMD_GPUs)
            {
                SMAMinerCheck.Interval = (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000);
            }

#if (SWITCH_TESTING)
            SMAMinerCheck.Interval = MiningDevice.SMAMinerCheckInterval;
#endif
            MinersManager.SwichMostProfitableGroupUpMethod(Globals.NiceHashData);
        }
Exemplo n.º 12
0
        private void MinerStatsCheck_Tick(object sender, EventArgs e)
        {
            MinersManager.MinerStatsCheck(Globals.NiceHashData);
            string json = JsonConvert.SerializeObject(hashData, Formatting.Indented);

            try
            {
                File.WriteAllText(Path.Combine(((DriveDirectory)server.Root).Path, "stats.json"), json);
            }
            catch (Exception ex)
            {
                // continue
            }
        }
Exemplo n.º 13
0
        private void UpdateGlobalRate()
        {
            double TotalRate = MinersManager.GetTotalRate();

            if (ConfigManager.GeneralConfig.AutoScaleBTCValues && TotalRate < 0.1)
            {
                toolStripStatusLabelBTCDayText.Text      = "mBTC/" + International.GetText("Day");
                toolStripStatusLabelGlobalRateValue.Text = (TotalRate * 1000).ToString("F5", CultureInfo.InvariantCulture);
            }
            else
            {
                toolStripStatusLabelBTCDayText.Text      = "BTC/" + International.GetText("Day");
                toolStripStatusLabelGlobalRateValue.Text = (TotalRate).ToString("F6", CultureInfo.InvariantCulture);
            }

            toolStripStatusLabelBTCDayValue.Text = ExchangeRateAPI.ConvertToActiveCurrency((TotalRate * Globals.BitcoinUSDRate)).ToString("F2", CultureInfo.InvariantCulture);
        }
Exemplo n.º 14
0
        private void SMAMinerCheck_Tick(object sender, EventArgs e)
        {
            SMAMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000);
            if (ComputeDeviceManager.Group.ContainsAMD_GPUs)
            {
                SMAMinerCheck.Interval = (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000);
            }

#if (SWITCH_TESTING)
            SMAMinerCheck.Interval = MiningDevice.SMAMinerCheckInterval;
#endif
            if (isSMAUpdated)    // Don't bother checking for new profits unless SMA has changed
            {
                isSMAUpdated = false;
                MinersManager.SwichMostProfitableGroupUpMethod(Globals.NiceHashData);
            }
        }
Exemplo n.º 15
0
        public static string GetNiceHashApiData(string url, string worker)
        {
            var responseFromServer = "";

            try
            {
                var activeMinersGroup = MinersManager.GetActiveMinersGroup();

                var wr = (HttpWebRequest)WebRequest.Create(url);
                wr.UserAgent = "NiceHashMiner/" + Application.ProductVersion;
                if (worker.Length > 64)
                {
                    worker = worker.Substring(0, 64);
                }
                wr.Headers.Add("NiceHash-Worker-ID", worker);
                wr.Headers.Add("NHM-Active-Miners-Group", activeMinersGroup);
                wr.Timeout = 30 * 1000;
                var response = wr.GetResponse();
                var ss       = response.GetResponseStream();
                if (ss != null)
                {
                    ss.ReadTimeout = 20 * 1000;
                    var reader = new StreamReader(ss);
                    responseFromServer = reader.ReadToEnd();
                    if (responseFromServer.Length == 0 || responseFromServer[0] != '{')
                    {
                        throw new Exception("Not JSON!");
                    }
                    reader.Close();
                }
                response.Close();
            }
            catch (Exception ex)
            {
                Helpers.ConsolePrint("NICEHASH", ex.Message);
                return(null);
            }

            return(responseFromServer);
        }
Exemplo n.º 16
0
        private static async void DeviceStatus_Tick(object state)
        {
            var devices    = ComputeDeviceManager.Available.Devices;
            var deviceList = new List <JArray>();
            var activeIDs  = MinersManager.GetActiveMinersIndexes();

            foreach (var device in devices)
            {
                try
                {
                    var array = new JArray
                    {
                        device.Index,
                        device.Name
                    };
                    Thread.Sleep(50);
                    var status = Convert.ToInt32(activeIDs.Contains(device.Index)) + ((int)device.DeviceType + 1) * 2;
                    array.Add(status);
                    array.Add((int)Math.Round(device.Load));
                    array.Add((int)Math.Round(device.Temp));
                    array.Add(device.FanSpeed);
                    deviceList.Add(array);
                }
                catch (Exception e) { Helpers.ConsolePrint("SOCKET", e.ToString()); }
            }
            var data = new NicehashDeviceStatus
            {
                devices = deviceList
            };
            var sendData = JsonConvert.SerializeObject(data);

            // This function is run every minute and sends data every run which has two auxiliary effects
            // Keeps connection alive and attempts reconnection if internet was dropped
            // _socket?.SendData(sendData);

            if (_socket != null)
            {
                await _socket.SendData(sendData);
            }
        }
Exemplo n.º 17
0
        private async void SMAMinerCheck_Tick(object sender, EventArgs e)
        {
            _smaMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 +
                                      R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000);
            if (ComputeDeviceManager.Group.ContainsAmdGpus)
            {
                _smaMinerCheck.Interval =
                    (ConfigManager.GeneralConfig.SwitchMinSecondsAMD +
                     ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 +
                    R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000);
            }

#if (SWITCH_TESTING)
            SMAMinerCheck.Interval = MiningDevice.SMAMinerCheckInterval;
#endif
            if (_isSmaUpdated)
            {
                // Don't bother checking for new profits unless SMA has changed
                _isSmaUpdated = false;
                await MinersManager.SwichMostProfitableGroupUpMethod();
            }
        }
Exemplo n.º 18
0
        public static async Task <string> GetNiceHashAPIData(string URL, string worker)
        {
            string ResponseFromServer;

            try
            {
                string ActiveMinersGroup = MinersManager.GetActiveMinersGroup();

                HttpWebRequest WR = (HttpWebRequest)WebRequest.Create(URL);
                WR.UserAgent = "NiceHashMiner/" + Application.ProductVersion;
                if (worker.Length > 64)
                {
                    worker = worker.Substring(0, 64);
                }
                WR.Headers.Add("NiceHash-Worker-ID", worker);
                WR.Headers.Add("NHM-Active-Miners-Group", ActiveMinersGroup);
                WR.Timeout = 30 * 1000;
                WebResponse Response = await WR.GetResponseAsync();

                Stream SS = Response.GetResponseStream();
                SS.ReadTimeout = 20 * 1000;
                StreamReader Reader = new StreamReader(SS);
                ResponseFromServer = await Reader.ReadToEndAsync();

                if (ResponseFromServer.Length == 0 || ResponseFromServer[0] != '{')
                {
                    throw new Exception("Not JSON!");
                }
                Reader.Close();
                Response.Close();
            }
            catch (Exception ex)
            {
                Helpers.ConsolePrint("NICEHASH", ex.Message);
                return(null);
            }

            return(ResponseFromServer);
        }
Exemplo n.º 19
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            MinersManager.StopAllMiners();

            MessageBoxManager.Unregister();
        }
Exemplo n.º 20
0
        private StartMiningReturnType StartMining(bool showWarnings)
        {
            if (textBoxBTCAddress.Text.Equals(""))
            {
                if (showWarnings)
                {
                    var result = MessageBox.Show(International.GetText("Form_Main_DemoModeMsg"),
                                                 International.GetText("Form_Main_DemoModeTitle"),
                                                 MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (result == DialogResult.Yes)
                    {
                        _demoMode             = true;
                        labelDemoMode.Visible = true;
                        labelDemoMode.Text    = International.GetText("Form_Main_DemoModeLabel");
                    }
                    else
                    {
                        return(StartMiningReturnType.IgnoreMsg);
                    }
                }
                else
                {
                    return(StartMiningReturnType.IgnoreMsg);

                    ;
                }
            }
            else if (!VerifyMiningAddress(true))
            {
                return(StartMiningReturnType.IgnoreMsg);
            }

            if (!NHSmaData.HasData)
            {
                if (showWarnings)
                {
                    MessageBox.Show(International.GetText("Form_Main_msgbox_NullNiceHashDataMsg"),
                                    International.GetText("Error_with_Exclamation"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(StartMiningReturnType.IgnoreMsg);
            }


            // Check if there are unbenchmakred algorithms
            var isBenchInit = true;

            foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices)
            {
                if (cdev.Enabled)
                {
                    if (cdev.GetAlgorithmSettings().Where(algo => algo.Enabled).Any(algo => algo.BenchmarkSpeed == 0))
                    {
                        isBenchInit = false;
                    }
                }
            }
            // Check if the user has run benchmark first
            if (!isBenchInit)
            {
                var result = DialogResult.No;
                if (showWarnings)
                {
                    result = MessageBox.Show(International.GetText("EnabledUnbenchmarkedAlgorithmsWarning"),
                                             International.GetText("Warning_with_Exclamation"),
                                             MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                }
                if (result == DialogResult.Yes)
                {
                    _benchmarkForm = new Form_Benchmark(
                        BenchmarkPerformanceType.Standard,
                        true);
                    SetChildFormCenter(_benchmarkForm);
                    _benchmarkForm.ShowDialog();
                    _benchmarkForm = null;
                    InitMainConfigGuiData();
                }
                else if (result == DialogResult.No)
                {
                    // check devices without benchmarks
                    foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices)
                    {
                        if (cdev.Enabled)
                        {
                            var enabled = cdev.GetAlgorithmSettings().Any(algo => algo.BenchmarkSpeed > 0);
                            cdev.Enabled = enabled;
                        }
                    }
                }
                else
                {
                    return(StartMiningReturnType.IgnoreMsg);
                }
            }

            textBoxBTCAddress.Enabled = false;
            textBoxWorkerName.Enabled = false;
            comboBoxLocation.Enabled  = false;
            buttonBenchmark.Enabled   = false;
            buttonStartMining.Enabled = false;
            buttonSettings.Enabled    = false;
            devicesListViewEnableControl1.IsMining = true;
            buttonStopMining.Enabled = true;

            // Disable profitable notification on start
            _isNotProfitable = false;

            ConfigManager.GeneralConfig.BitcoinAddress  = textBoxBTCAddress.Text.Trim();
            ConfigManager.GeneralConfig.WorkerName      = textBoxWorkerName.Text.Trim();
            ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex;

            InitFlowPanelStart();
            ClearRatesAll();

            var btcAdress = _demoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim();
            var isMining  = MinersManager.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex],
                                                          textBoxWorkerName.Text.Trim(), btcAdress);

            if (!_demoMode)
            {
                ConfigManager.GeneralConfigFileCommit();
            }

            //_isSmaUpdated = true; // Always check profits on mining start
            //_smaMinerCheck.Interval = 100;
            //_smaMinerCheck.Start();
            _minerStatsCheck.Start();

            if (ConfigManager.GeneralConfig.RunScriptOnCUDA_GPU_Lost)
            {
                _computeDevicesCheckTimer          = new SystemTimer();
                _computeDevicesCheckTimer.Elapsed += ComputeDevicesCheckTimer_Tick;
                _computeDevicesCheckTimer.Interval = 60000;

                _computeDevicesCheckTimer.Start();
            }

            return(isMining ? StartMiningReturnType.StartMining : StartMiningReturnType.ShowNoMining);
        }
Exemplo n.º 21
0
//        [Obsolete("Deprecated in favour of AlgorithmSwitchingManager timer")]
//       private async void SMAMinerCheck_Tick(object sender, EventArgs e)
//        {
//            _smaMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 +
//                                      R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000);
//            if (ComputeDeviceManager.Group.ContainsAmdGpus)
//            {
//                _smaMinerCheck.Interval =
//                    (ConfigManager.GeneralConfig.SwitchMinSecondsAMD +
//                     ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 +
//                    R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000);
//            }

//#if (SWITCH_TESTING)
//            SMAMinerCheck.Interval = MiningDevice.SMAMinerCheckInterval;
//#endif
//            if (_isSmaUpdated)
//            {
//                // Don't bother checking for new profits unless SMA has changed
//                _isSmaUpdated = false;
//                await MinersManager.SwichMostProfitableGroupUpMethod();
//            }
//        }

        private static async void MinerStatsCheck_Tick(object sender, EventArgs e)
        {
            await MinersManager.MinerStatsCheck();
        }
Exemplo n.º 22
0
 public override Task OnDisconnectedAsync(Exception exception)
 {
     MinersManager.RemoveMiner(this.XUser, this.XWorker);
     return(base.OnDisconnectedAsync(exception));
 }
Exemplo n.º 23
0
 private static bool IsCPU_eqm(MiningPair a)
 {
     return(MinersManager.EquihashCPU_USE_eqm() && a.Device.DeviceType == DeviceType.CPU);
 }
Exemplo n.º 24
0
        private StartMiningReturnType StartMining(bool showWarnings)
        {
            if (textBoxBTCAddress.Text.Equals(""))
            {
                if (showWarnings)
                {
                    DialogResult result = MessageBox.Show(International.GetText("Form_Main_DemoModeMsg"),
                                                          International.GetText("Form_Main_DemoModeTitle"),
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        DemoMode = true;
                        labelDemoMode.Visible = true;
                        labelDemoMode.Text    = International.GetText("Form_Main_DemoModeLabel");
                    }
                    else
                    {
                        return(StartMiningReturnType.IgnoreMsg);
                    }
                }
                else
                {
                    return(StartMiningReturnType.IgnoreMsg);;
                }
            }
            else if (!VerifyMiningAddress(true))
            {
                return(StartMiningReturnType.IgnoreMsg);
            }

            if (Globals.NiceHashData == null)
            {
                if (showWarnings)
                {
                    MessageBox.Show(International.GetText("Form_Main_msgbox_NullNiceHashDataMsg"),
                                    International.GetText("Error_with_Exclamation"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(StartMiningReturnType.IgnoreMsg);
            }


            // Check if there are unbenchmakred algorithms
            bool isBenchInit       = true;
            bool hasAnyAlgoEnabled = false;

            foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices)
            {
                if (cdev.Enabled)
                {
                    foreach (var algo in cdev.GetAlgorithmSettings())
                    {
                        if (algo.Enabled == true)
                        {
                            hasAnyAlgoEnabled = true;
                            if (algo.BenchmarkSpeed == 0)
                            {
                                isBenchInit = false;
                                break;
                            }
                        }
                    }
                }
            }
            // Check if the user has run benchmark first
            if (!isBenchInit)
            {
                DialogResult result = DialogResult.No;
                if (showWarnings)
                {
                    result = MessageBox.Show(International.GetText("EnabledUnbenchmarkedAlgorithmsWarning"),
                                             International.GetText("Warning_with_Exclamation"),
                                             MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                }
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    BenchmarkForm = new Form_Benchmark(
                        BenchmarkPerformanceType.Standard,
                        true);
                    SetChildFormCenter(BenchmarkForm);
                    BenchmarkForm.ShowDialog();
                    BenchmarkForm = null;
                    InitMainConfigGUIData();
                }
                else if (result == System.Windows.Forms.DialogResult.No)
                {
                    // check devices without benchmarks
                    foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices)
                    {
                        if (cdev.Enabled)
                        {
                            bool Enabled = false;
                            foreach (var algo in cdev.GetAlgorithmSettings())
                            {
                                if (algo.BenchmarkSpeed > 0)
                                {
                                    Enabled = true;
                                    break;
                                }
                            }
                            cdev.Enabled = Enabled;
                        }
                    }
                }
                else
                {
                    return(StartMiningReturnType.IgnoreMsg);
                }
            }

            textBoxBTCAddress.Enabled = false;
            textBoxWorkerName.Enabled = false;
            comboBoxLocation.Enabled  = false;
            buttonBenchmark.Enabled   = false;
            buttonStartMining.Enabled = false;
            buttonSettings.Enabled    = false;
            devicesListViewEnableControl1.IsMining = true;
            buttonStopMining.Enabled = true;

            // Disable profitable notification on start
            IsNotProfitable = false;

            ConfigManager.GeneralConfig.BitcoinAddress  = textBoxBTCAddress.Text.Trim();
            ConfigManager.GeneralConfig.WorkerName      = textBoxWorkerName.Text.Trim();
            ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex;

            InitFlowPanelStart();
            ClearRatesALL();

            var btcAdress = DemoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim();
            var isMining  = MinersManager.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex], textBoxWorkerName.Text.Trim(), btcAdress);

            if (!DemoMode)
            {
                ConfigManager.GeneralConfigFileCommit();
            }

            isSMAUpdated           = true; // Always check profits on mining start
            SMAMinerCheck.Interval = 100;
            SMAMinerCheck.Start();
            MinerStatsCheck.Start();

            return(isMining ? StartMiningReturnType.StartMining : StartMiningReturnType.ShowNoMining);
        }
        private StartMiningReturnType StartMining(bool showWarnings)
        {
            if (textBoxBTCAddress.Text.Equals(""))
            {
                if (showWarnings)
                {
                    var result = MessageBox.Show(Tr("You have not entered a bitcoin address. NiceHash Miner Legacy will start mining in DEMO mode. In the DEMO mode, you can test run the miner and be able see how much you can earn using your computer. Would you like to continue in DEMO mode?\n\nDISCLAIMER: YOU WILL NOT EARN ANYTHING DURING DEMO MODE!"),
                                                 Tr("Start mining in DEMO mode?"),
                                                 MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (result == DialogResult.Yes)
                    {
                        _demoMode             = true;
                        labelDemoMode.Visible = true;
                        labelDemoMode.Text    = Tr("NiceHash Miner Legacy is running in DEMO mode!");
                    }
                    else
                    {
                        return(StartMiningReturnType.IgnoreMsg);
                    }
                }
                else
                {
                    return(StartMiningReturnType.IgnoreMsg);
                }
            }
            else if (!VerifyMiningAddress(true))
            {
                return(StartMiningReturnType.IgnoreMsg);
            }

            var hasData = NHSmaData.HasData;

            if (!showWarnings)
            {
                for (var i = 0; i < 10; i++)
                {
                    if (hasData)
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                    hasData = NHSmaData.HasData;
                    Helpers.ConsolePrint("NICEHASH", $"After {i}s has data: {hasData}");
                }
            }

            if (!hasData)
            {
                Helpers.ConsolePrint("NICEHASH", "No data received within timeout");
                if (showWarnings)
                {
                    MessageBox.Show(Tr("Unable to get NiceHash profitability data. If you are connected to internet, try again later."),
                                    Tr("Error!"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(StartMiningReturnType.IgnoreMsg);
            }


            // Check if there are unbenchmakred algorithms
            var isBenchInit = true;

            foreach (var cdev in ComputeDeviceManager.Available.Devices)
            {
                if (cdev.Enabled)
                {
                    if (cdev.GetAlgorithmSettings().Where(algo => algo.Enabled).Any(algo => algo.BenchmarkSpeed == 0))
                    {
                        isBenchInit = false;
                    }
                }
            }
            // Check if the user has run benchmark first
            if (!isBenchInit)
            {
                var result = DialogResult.No;
                if (showWarnings)
                {
                    result = MessageBox.Show(Tr("There are unbenchmarked algorithms for selected enabled devices. Click Yes to benchmark and start mining, No to skip benchmark and continue mining, Cancel to abort"),
                                             Tr("Warning!"),
                                             MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                }
                if (result == DialogResult.Yes)
                {
                    _benchmarkForm = new Form_Benchmark(
                        BenchmarkPerformanceType.Standard,
                        true);
                    SetChildFormCenter(_benchmarkForm);
                    _benchmarkForm.ShowDialog();
                    _benchmarkForm = null;
                    InitMainConfigGuiData();
                }
                else if (result == DialogResult.No)
                {
                    // check devices without benchmarks
                    foreach (var cdev in ComputeDeviceManager.Available.Devices)
                    {
                        if (cdev.Enabled)
                        {
                            var enabled = cdev.GetAlgorithmSettings().Any(algo => algo.BenchmarkSpeed > 0);
                            cdev.Enabled = enabled;
                        }
                    }
                }
                else
                {
                    return(StartMiningReturnType.IgnoreMsg);
                }
            }

            textBoxBTCAddress.Enabled = false;
            textBoxWorkerName.Enabled = false;
            comboBoxLocation.Enabled  = false;
            buttonBenchmark.Enabled   = false;
            buttonStartMining.Enabled = false;
            buttonSettings.Enabled    = false;
            devicesListViewEnableControl1.IsMining = true;
            buttonStopMining.Enabled = true;

            // Disable profitable notification on start
            _isNotProfitable = false;

            ConfigManager.GeneralConfig.BitcoinAddress  = textBoxBTCAddress.Text.Trim();
            ConfigManager.GeneralConfig.WorkerName      = textBoxWorkerName.Text.Trim();
            ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex;

            InitFlowPanelStart();
            ClearRatesAll();

            var btcAdress = _demoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim();
            var isMining  = MinersManager.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex],
                                                          textBoxWorkerName.Text.Trim(), btcAdress);

            if (!_demoMode)
            {
                ConfigManager.GeneralConfigFileCommit();
            }

            //_isSmaUpdated = true; // Always check profits on mining start
            //_smaMinerCheck.Interval = 100;
            //_smaMinerCheck.Start();
            _minerStatsCheck.Start();

            if (ConfigManager.GeneralConfig.RunScriptOnCUDA_GPU_Lost)
            {
                _computeDevicesCheckTimer          = new SystemTimer();
                _computeDevicesCheckTimer.Elapsed += ComputeDevicesCheckTimer_Tick;
                _computeDevicesCheckTimer.Interval = 60000;

                _computeDevicesCheckTimer.Start();
            }

            return(isMining ? StartMiningReturnType.StartMining : StartMiningReturnType.ShowNoMining);
        }
Exemplo n.º 26
0
 public Task ReportHashrate(decimal rate)
 {
     MinersManager.ReportHashrate(this.XUser, this.XWorker, rate);
     return(Task.CompletedTask);
 }
Exemplo n.º 27
0
 private void MinerStatsCheck_Tick(object sender, EventArgs e)
 {
     MinersManager.MinerStatsCheck(Globals.NiceHashData);
 }
Exemplo n.º 28
0
        void NextBenchmark()
        {
            if (_bechmarkCurrentIndex > -1)
            {
                StepUpBenchmarkStepProgress();
            }
            ++_bechmarkCurrentIndex;
            if (_bechmarkCurrentIndex >= _benchmarkAlgorithmsCount)
            {
                EndBenchmark();
                return;
            }

            Tuple <ComputeDevice, Queue <Algorithm> > currentDeviceAlgosTuple;
            Queue <Algorithm> algorithmBenchmarkQueue;

            while (_benchmarkDevicesAlgorithmQueue.Count > 0)
            {
                currentDeviceAlgosTuple = _benchmarkDevicesAlgorithmQueue[0];
                _currentDevice          = currentDeviceAlgosTuple.Item1;
                algorithmBenchmarkQueue = currentDeviceAlgosTuple.Item2;
                if (algorithmBenchmarkQueue.Count != 0)
                {
                    _currentAlgorithm = algorithmBenchmarkQueue.Dequeue();
                    break;
                }
                else
                {
                    _benchmarkDevicesAlgorithmQueue.RemoveAt(0);
                }
            }

            var currentConfig = _currentDevice.DeviceBenchmarkConfig;

            if (_currentDevice.DeviceGroupType == DeviceGroupType.CPU)
            {
                _currentMiner = MinersManager.GetCpuMiner(_currentDevice.Group);
            }
            else
            {
                _currentMiner = MinersManager.CreateMiner(currentConfig.DeviceGroupType, _currentAlgorithm.NiceHashID);
            }

            if (_currentMiner != null && _currentAlgorithm != null)
            {
                _benchmarkMiners.Add(_currentMiner);
                CurrentAlgoName = AlgorithmNiceHashNames.GetName(_currentAlgorithm.NiceHashID);
                // this has no effect for CPU miners
                _currentMiner.SetCDevs(new string[] { _currentDevice.UUID });

                var time = ConfigManager.Instance.GeneralConfig.BenchmarkTimeLimits
                           .GetBenchamrktime(benchmarkOptions1.PerformanceType, _currentDevice.DeviceGroupType);
                //currentConfig.TimeLimit = time;

                // dagger about 4 minutes
                var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

                dotCount = 0;
                _benchmarkingTimer.Start();

                _currentMiner.BenchmarkStart(_currentDevice, _currentAlgorithm, time, this);
                algorithmsListView1.SetSpeedStatus(_currentDevice, _currentAlgorithm.NiceHashID,
                                                   getDotsWaitString());
            }
            else
            {
                NextBenchmark();
            }
        }
Exemplo n.º 29
0
        void NextBenchmark()
        {
            if (_bechmarkCurrentIndex > -1)
            {
                StepUpBenchmarkStepProgress();
            }
            ++_bechmarkCurrentIndex;
            if (_bechmarkCurrentIndex >= _benchmarkAlgorithmsCount)
            {
                EndBenchmark();
                return;
            }

            Tuple <ComputeDevice, Queue <Algorithm> > currentDeviceAlgosTuple;
            Queue <Algorithm> algorithmBenchmarkQueue;

            while (_benchmarkDevicesAlgorithmQueue.Count > 0)
            {
                currentDeviceAlgosTuple = _benchmarkDevicesAlgorithmQueue[0];
                _currentDevice          = currentDeviceAlgosTuple.Item1;
                algorithmBenchmarkQueue = currentDeviceAlgosTuple.Item2;
                if (algorithmBenchmarkQueue.Count != 0)
                {
                    _currentAlgorithm = algorithmBenchmarkQueue.Dequeue();
                    break;
                }
                else
                {
                    _benchmarkDevicesAlgorithmQueue.RemoveAt(0);
                }
            }

            if (_currentDevice != null && _currentAlgorithm != null)
            {
                _currentMiner = MinersManager.CreateMiner(_currentDevice, _currentAlgorithm);
                if (_currentDevice.DeviceType == DeviceType.CPU && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters))
                {
                    __CPUBenchmarkStatus          = new CPUBenchmarkStatus();
                    _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.LessTreads;
                }
                else
                {
                    __CPUBenchmarkStatus = null;
                }
            }

            if (_currentMiner != null && _currentAlgorithm != null)
            {
                _benchmarkMiners.Add(_currentMiner);
                CurrentAlgoName = AlgorithmNiceHashNames.GetName(_currentAlgorithm.NiceHashID);
                _currentMiner.InitBenchmarkSetup(new MiningPair(_currentDevice, _currentAlgorithm));

                var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
                           .GetBenchamrktime(benchmarkOptions1.PerformanceType, _currentDevice.DeviceGroupType);
                //currentConfig.TimeLimit = time;
                if (__CPUBenchmarkStatus != null)
                {
                    __CPUBenchmarkStatus.Time = time;
                }

                // dagger about 4 minutes
                var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

                dotCount = 0;
                _benchmarkingTimer.Start();

                _currentMiner.BenchmarkStart(time, this);
                algorithmsListView1.SetSpeedStatus(_currentDevice, _currentAlgorithm.NiceHashID,
                                                   getDotsWaitString());
            }
            else
            {
                NextBenchmark();
            }
        }
Exemplo n.º 30
0
 private static async void MinerStatsCheck_Tick(object sender, EventArgs e)
 {
     await MinersManager.MinerStatsCheck(Globals.NiceHashData);
 }