public void StopMiner() { if (!_process.IsRunning()) { _process = null; return; } LogActivity(_donationMiningMode == MiningModeEnum.Donation ? "DonationStop" : "Stop"); WriteConsole(string.Format("Stopping {0} {1}", _currentRunning.ServicePrint, _currentRunning.AlgoName), true); RecordMiningTime(); if (MinerKillMode == 0) { ProcessUtil.KillProcess(_process); } else { ProcessUtil.KillProcessAndChildren(_process.Id); } _process = null; _donationMiningMode = MiningModeEnum.Stopped; if (_currentRunning != null) { PriceEntryBase entry = PriceEntries.Single(o => o.Id == _currentRunning.Id); entry.UpdateStatus(); } if (_stoppedMining == null) { _stoppedMining = DateTime.Now; } _currentRunning = null; }
private void dgPrices_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridView senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn && e.RowIndex >= 0) { IList <PriceEntryBase> data = senderGrid.DataSource as IList <PriceEntryBase>; PriceEntryBase entry = data[e.RowIndex]; switch ((bool)dgPrices.CurrentCell.FormattedValue) { case true: dgPrices.CurrentCell.Value = "false"; entry.Enabled = false; // entry.Banned = true; dgPrices.CurrentRow.DefaultCellStyle.ForeColor = Color.DarkGray; break; case false: dgPrices.CurrentCell.Value = "true"; entry.Enabled = true; // entry.Banned = false; dgPrices.CurrentRow.DefaultCellStyle.ForeColor = Color.Black; break; } UpdateGrid(); } }
public void RequestStart(ServiceEnum service, string algo, bool isMinimizedToTray) { PriceEntryBase entry = null; foreach (PriceEntryBase priceEntry in _priceEntries) { if (priceEntry.AlgoName == algo) { entry = priceEntry; if (priceEntry.ServiceEntry.ServiceEnum == service) { break; } } } if (entry == null) { RunBestAlgo(isMinimizedToTray); } else { StartMiner(entry, isMinimizedToTray); } }
private void CheckBoxUpdate() { int _stActive = 1; if (dgPrices.Columns.Contains("Active")) { _stActive = dgPrices.Columns.IndexOf(dgPrices.Columns["Active"]); } foreach (DataGridViewRow row in dgPrices.Rows) { IList <PriceEntryBase> data = dgPrices.DataSource as IList <PriceEntryBase>; PriceEntryBase entry = data[row.Index]; if (entry.Enabled == true) { row.Cells[_stActive].Value = "true"; } else { row.Cells[_stActive].Value = "false"; row.DefaultCellStyle.ForeColor = Color.DarkGray; } } }
public void GetPrices(float price, float er, float price24, float er24, string cname, bool _lagstatus) { float ep = 0; float ex = 0; switch (_pricemode) { case 1: ep = price24; ex = er24; break; default: ep = price; ex = er; break; } PriceEntryBase entry = GetEntryCoin(cname.ToString().ToLower()); if (entry == null) { entry = GetEntryCoin(WTMTranslation(cname.ToLower()).ToString().ToLower()); } if (entry != null) { lock (MiningEngine) { { entry.Price = (decimal)ep * 1000000000; entry.ExRate = (decimal)ex; PriceDynamics(price, er, price24, er24, entry); //AveragePrice(entry); entry.Lagging = _lagstatus; if (MiningEngine._pumpreduction == true && entry.Pumping == true) { entry.Price = entry.Price / ((decimal)(entry.AvgExRate / er24) - MiningEngine._dynoffset / 100); entry.PumpReduction = true; } else { entry.PumpReduction = false; } entry.DynUpdated = DateTime.Now; } MiningEngine.PricesUpdated = true; MiningEngine.HasPrices = true; LastUpdated = DateTime.Now; UpdateHistory(); } } }
private string ActiveTime(PriceEntryBase priceEntry) { TimeSpan time = priceEntry.TimeMining; if (_engine.CurrentRunning == priceEntry.Id && _engine.StartMining.HasValue) { time += (DateTime.Now - _engine.StartMining.Value); } return(time.FormatTime()); }
private void dgPrices_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridView senderGrid = (DataGridView)sender; if (e.RowIndex >= 0) { IList <PriceEntryBase> data = senderGrid.DataSource as IList <PriceEntryBase>; PriceEntryBase entry = data[e.RowIndex]; _engine.SwitchBanStatus(entry.ServicePrint); UpdateGrid(); } }
private string DetectNiceHashStratum(PriceEntryBase entry) { if (entry.ServiceEntry.ServiceName != "NiceHash" && entry.ServiceEntry.ServiceName != "WestHash") { return(string.Empty); } NiceHashService niceHash = entry.ServiceEntry as NiceHashService; if (niceHash == null || niceHash.DetectStratum == false) { return(string.Empty); } return("-o stratum+tcp://" + niceHash.GetBestStratum(entry.AlgoName) + " "); }
private void MPOSFee(object RawData) { if (RawData != null) { JObject data = (JObject)RawData; JToken gpi = data["getpoolinfo"]; JToken dat = gpi["data"]; JToken tag = dat["currency"]; JToken fee = (float)dat["fees"]; PriceEntryBase entry = GetEntryTag(tag.ToString().ToLower()); if (entry != null) { entry.FeePercent = 1 - (1 - (decimal)fee / 100) * (1 - _BtcFee / 100); } } }
private void MPOSBalances(object RawData) { if (RawData != null) { JObject data = (JObject)RawData; JToken gub = data["getuserbalance"]; JToken bal = gub["data"]; float confirmed = (float)bal["confirmed"]; float unpaid = (float)bal["unconfirmed"]; JToken status = data["getuserbalance"]["version"]; PriceEntryBase entry = GetEntryCoin(status.ToString().ToLower()); if (entry != null) { entry.Balance = confirmed.ExtractDecimal(); entry.Pending = unpaid.ExtractDecimal(); entry.BalanceBTC = confirmed.ExtractDecimal() * entry.ExRate; } } }
private void dgPrices_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (_engine.MiningMode != MiningModeEnum.Stopped) { return; } DataGridView senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { IList <PriceEntryBase> data = senderGrid.DataSource as IList <PriceEntryBase>; PriceEntryBase entry = data[e.RowIndex]; _engine.MiningMode = MiningModeEnum.Manual; UpdateButtons(); _engine.RequestStart(entry.Id, IsMinimizedToTray); UpdateGrid(); } }
private void APIProcessData(object RawData) { if (RawData != null) { float bal = 0; float pend = 0; float hashrate = 0; JObject data = (JObject)RawData; bal = (float)data["confirmed_rewards"]; pend = (float)data["round_estimate"]; string cname = data["username"].ToString(); hashrate = (float)data["total_hashrate"]; JToken workers = data["workers"]; PriceEntryBase entry = GetEntryCoin(cname.ToString()); if (entry != null) { entry.Balance = bal.ExtractDecimal(); entry.Pending = pend.ExtractDecimal(); entry.BalanceBTC = entry.Balance * entry.ExRate; if (_nospeed == false) { entry.AcceptSpeed = hashrate.ExtractDecimal(); } if (_nospeedworker == false && workers != null) { foreach (JProperty item in workers.Children()) { var s = (float)item.Value["hashrate"]; if (item.Name.ToString().ToLower() == _account.ToString().ToLower() + "." + _worker.ToString().ToLower() && s > 0) { entry.AcSpWrk = s.ExtractDecimal(); AverageSpeed(entry); } } } } } }
public void ReadData(IDictionary <string, object> data) { ExtractCommon(data); object[] items = data["algos"] as object[]; foreach (object rawitem in items) { Dictionary <string, object> item = rawitem as Dictionary <string, object>; PriceEntryBase entry = CreateEntry(item); if (!MiningEngine._showinactive && !entry.Enabled) { continue; } else { MiningEngine.PriceEntries.Add(entry); } } }
public void UpdatePrice(PriceEntryBase priceEntryBase) { DateTime now = DateTime.Now; decimal price = priceEntryBase.NetEarn; decimal totalPrice = price; int totalCount = PriceList.Count; List <decimal> window = new List <decimal> { price }; decimal windowedPrice = price; int windowedCount = 0; bool outlier = false; if (!PriceList.ContainsKey(priceEntryBase)) { PriceList.Add(priceEntryBase, new List <PriceStat>()); } foreach (PriceStat stat in PriceList[priceEntryBase]) { if (stat.CurrentPrice > 0) { decimal historicPrice = stat.CurrentPrice; totalPrice += historicPrice; if (stat.Time == now) { return; } if (stat.Time >= now - _statWindow) { window.Add(historicPrice); windowedPrice += historicPrice; windowedCount++; } } } decimal totalAveragePrice = totalPrice / (totalCount + 1); decimal windowedAveragePrice = windowedPrice / (windowedCount + 1); if (windowedCount >= 10) // Makes sure at least ten entries are in there { window.Sort(); if (_iqrMultiplier > 0) { double sumOfSquareOfDifferences = (double)PriceList[priceEntryBase].Where(stat => stat.Time >= now - _statWindow) .Sum(stat => (stat.CurrentPrice - windowedAveragePrice) * (stat.CurrentPrice - windowedAveragePrice)); decimal standardDeviation = (decimal)Math.Sqrt(sumOfSquareOfDifferences / windowedCount); decimal top = windowedAveragePrice + standardDeviation; decimal bottom = windowedAveragePrice - standardDeviation; decimal iqr = top - bottom; decimal max = windowedAveragePrice + (iqr * _iqrMultiplier); outlier = price > max; } else { // If the IQR multiplier is negative or zero, // it'll try to use percentiles for outlierdetection // Not advised! Will kill off trending profits, iqr-multiplying is preferable int outlierIndex = (int)Math.Truncate(window.Count * _percentile); decimal[] outliers = { window[outlierIndex], window[window.Count - outlierIndex] }; outlier = price > outliers.Max(); } } PriceStat priceStat = new PriceStat { Time = now, CurrentPrice = price, TotalAveragePrice = totalAveragePrice, WindowedAveragePrice = windowedAveragePrice, Outlier = outlier }; priceEntryBase.Outlier = outlier; priceEntryBase.NetAverage = windowedAveragePrice; // if (priceEntryBase.Enabled == true) PriceList[priceEntryBase].Add(priceStat); }
private void StartMiner(PriceEntryBase entry, bool isMinimizedToTray = false) { _nextRun = null; _nextRunFromTime = null; _currentRunning = entry; _startMining = DateTime.Now; _process = new Process(); if (_donationMiningMode == MiningModeEnum.Donation) { if (!string.IsNullOrWhiteSpace(entry.DonationFolder)) { _process.StartInfo.WorkingDirectory = entry.DonationFolder; } _process.StartInfo.FileName = string.IsNullOrWhiteSpace(entry.DonationFolder) ? entry.DonationCommand : string.Format(@"{0}\{1}", entry.DonationFolder, entry.DonationCommand); _process.StartInfo.Arguments = entry.DonationArguments; } else { if (!string.IsNullOrWhiteSpace(entry.Folder)) { _process.StartInfo.WorkingDirectory = entry.Folder; } _process.StartInfo.FileName = string.IsNullOrWhiteSpace(entry.Folder) ? entry.Command : string.Format(@"{0}\{1}", entry.Folder, entry.Command); _process.StartInfo.Arguments = entry.Arguments; } WriteConsole(string.Format("Starting {0} {1} with {2} {3}", _currentRunning.ServicePrint, _currentRunning.Name, _process.StartInfo.FileName, _process.StartInfo.Arguments), true); if (!string.IsNullOrWhiteSpace(_process.StartInfo.WorkingDirectory) && !Directory.Exists(_process.StartInfo.WorkingDirectory)) { entry.DeadTime = DateTime.Now; var message = string.Format("Path '{0}' does not exist.", _process.StartInfo.WorkingDirectory); _process = null; WriteConsole(message, true); throw new ArgumentException(message); } if (!string.IsNullOrWhiteSpace(_process.StartInfo.FileName) && !File.Exists(_process.StartInfo.FileName)) { entry.DeadTime = DateTime.Now; var message = string.Format("File '{0}' does not exist.", _process.StartInfo.FileName); _process = null; WriteConsole(message, true); throw new ArgumentException(message); } if (entry.UseWindow) { _process.StartInfo.WindowStyle = (isMinimizedToTray && TrayMode == 2) ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Minimized; _process.Start(); Thread.Sleep(100); try { ProcessUtil.SetWindowTitle(_process, string.Format("{0} {1} Miner", entry.ServicePrint, entry.Name)); } catch (Exception ex) { ErrorLogger.Log(ex); } if (isMinimizedToTray && TrayMode == 1) { HideMinerWindow(); } } else { _process.StartInfo.RedirectStandardOutput = true; _process.StartInfo.RedirectStandardError = true; _process.EnableRaisingEvents = true; _process.StartInfo.CreateNoWindow = true; _process.StartInfo.UseShellExecute = false; _process.ErrorDataReceived += ProcessConsoleOutput; _process.OutputDataReceived += ProcessConsoleOutput; _process.Start(); _process.BeginOutputReadLine(); _process.BeginErrorReadLine(); } _startMining = DateTime.Now; _donationMiningMode = MiningMode; entry.UpdateStatus(); LogActivity(_donationMiningMode == MiningModeEnum.Donation ? "DonationStart" : "Start"); }
public void RunBestAlgo(bool isMinimizedToTray) { try { // Check for dead process if (!_process.IsRunning() && _currentRunning != null) { lock (this) { _currentRunning.DeadTime = DateTime.Now; LogActivity(_donationMiningMode == MiningModeEnum.Donation ? "DonationDead" : "Dead"); WriteConsole(string.Format("Dead {0} {1}", _currentRunning.ServicePrint, _currentRunning.Name), true); RecordMiningTime(); } } // Clear information if process not running if (_process == null || _process.HasExited) { _currentRunning = null; _startMining = null; _nextRun = null; _nextRunFromTime = null; } // Donation mining if (DoDonationMinging) { if (_donationMiningMode == MiningModeEnum.Automatic && TimeUntilDonation == TimeSpan.Zero) { StopMiner(); _donationMiningMode = MiningModeEnum.Donation; MiningMode = _donationMiningMode; _autoMiningTime = TimeSpan.Zero; } else if (_donationMiningMode == MiningModeEnum.Donation && TimeDuringDonation == TimeSpan.Zero) { StopMiner(); _donationMiningMode = MiningModeEnum.Automatic; MiningMode = _donationMiningMode; _donationMiningTime = TimeSpan.Zero; } } // Restart miner if max time reached if (RestartTime.HasValue && RestartTime.Value <= TimeSpan.Zero) { StopMiner(); } // Find the best, live entry var best = _donationMiningMode == MiningModeEnum.Donation ? _priceEntries .Where(o => !o.IsDead) .Where(o => !string.IsNullOrWhiteSpace(o.DonationCommand)) .OrderByDescending(o => o.NetEarn) .First() : _priceEntries .Where(o => !o.IsDead) .Where(o => !string.IsNullOrWhiteSpace(o.Command)) .OrderByDescending(o => o.NetEarn) .First(); // Handle minimum time for better algorithm before switching if (_switchTime > TimeSpan.Zero && _currentRunning != null) { if (!_nextRun.HasValue && _currentRunning.Id != best.Id) { _nextRun = best.Id; _nextRunFromTime = DateTime.Now; } else if (_nextRun.HasValue && _currentRunning.Id == best.Id) { _nextRun = null; _nextRunFromTime = null; } if (NextRunTime.HasValue && NextRunTime > TimeSpan.Zero) { best = _priceEntries.First(o => o.Id == _currentRunning.Id); } } // Update undead entries var entries = PriceEntries.Where(o => !o.IsDead && o.DeadTime != DateTime.MinValue); foreach (var entry in entries) { entry.DeadTime = DateTime.MinValue; } // Just update time if we are already running the right entry if (_currentRunning != null && _currentRunning.Id == best.Id) { _currentRunning.UpdateStatus(); return; } // Honor minimum time to run in auto mode if (MiningTime.HasValue && MiningTime.Value < _minTime) { _currentRunning.UpdateStatus(); return; } StopMiner(); StartMiner(best, isMinimizedToTray); } catch (Exception ex) { ErrorLogger.Log(ex); } }
public void RunBestAlgo(bool isMinimizedToTray) { try { // Check for dead process if (!_process.IsRunning() && _currentRunning != null) { lock (this) { _currentRunning.DeadTime = DateTime.Now; LogActivity(_donationMiningMode == MiningModeEnum.Donation ? "DonationDead" : "Dead"); WriteConsole(string.Format("Dead {0} {1}", _currentRunning.ServicePrint, _currentRunning.Name), true); RecordMiningTime(); } } // Clear information if process not running if (!_process.IsRunning()) { _currentRunning = null; _startMining = null; _nextRun = null; _nextRunFromTime = null; } // Donation mining if (DoDonationMinging) { if (_donationMiningMode == MiningModeEnum.Automatic && TimeUntilDonation == TimeSpan.Zero) { StopMiner(); _donationMiningMode = MiningModeEnum.Donation; MiningMode = _donationMiningMode; _autoMiningTime = TimeSpan.Zero; } else if (_donationMiningMode == MiningModeEnum.Donation && TimeDuringDonation == TimeSpan.Zero) { StopMiner(); _donationMiningMode = MiningModeEnum.Automatic; MiningMode = _donationMiningMode; _donationMiningTime = TimeSpan.Zero; } } // Restart miner if max time reached if (RestartTime.HasValue && RestartTime.Value <= TimeSpan.Zero) { StopMiner(); } foreach (PriceEntryBase entry in _priceEntries) { entry.BelowMinPrice = entry.NetEarn < _minPrice; } // Find the best, live entry PriceEntryBase best = _priceEntries .Where(o => !IsBadEntry(o)) .Where(o => !string.IsNullOrWhiteSpace(_donationMiningMode == MiningModeEnum.Donation ? o.DonationCommand : o.Command)) .OrderByDescending(o => _mineByAverage? o.NetAverage: o.NetEarn) .FirstOrDefault(); // If none is found, because they're all banned, dead, below minprice // All should quit if (best == null && _currentRunning != null) { StopMiner(); return; } // If the current pool is banned, it should directly start the best one if (_currentRunning != null && _currentRunning.Banned && best.Id != _currentRunning.Id) { StopMiner(); StartMiner(best, isMinimizedToTray); return; } decimal highestMinProfit = 1M; // Handle minimum time for better algorithm before switching if (_switchTime > TimeSpan.Zero && _currentRunning != null) { if (!_nextRun.HasValue && _currentRunning.Id != best.Id) { _nextRun = best.Id; _nextRunFromTime = DateTime.Now; } else if (_nextRun.HasValue && _currentRunning.Id == best.Id) { _nextRun = null; _nextRunFromTime = null; } _profitBestOverRunning = _mineByAverage? best.NetAverage / _currentRunning.NetAverage : best.NetEarn / _currentRunning.NetEarn; highestMinProfit = best.ServiceEntry.ServiceEnum != _currentRunning.ServiceEntry.ServiceEnum ? Math.Max(best.MinProfit, _minProfit) : _minProfit; if (NextRunTime.HasValue && NextRunTime > TimeSpan.Zero) { best = _priceEntries.First(o => o.Id == _currentRunning.Id); } } // Update undead entries IEnumerable <PriceEntryBase> entries = PriceEntries.Where(o => !o.IsDead && o.DeadTime != DateTime.MinValue); foreach (PriceEntryBase entry in entries) { entry.DeadTime = DateTime.MinValue; } if (_currentRunning != null // Guarantees a minimum profit before switching && (_profitBestOverRunning < highestMinProfit // Keeps outliers pending/ignores them if requested and not mining by average || (!_mineByAverage && _ignoreOutliers && best.Outlier) // Just update time if we are already running the right entry || _currentRunning.Id == best.Id // Honor minimum time to run in auto mode || (MiningTime.HasValue && MiningTime.Value < _minTime))) { _currentRunning.UpdateStatus(); return; } StopMiner(); if (_stoppedMining == null || _stoppedMining + _delay <= DateTime.Now) { StartMiner(best, isMinimizedToTray); } } catch (Exception ex) { ErrorLogger.Log(ex); } }
public void UpdatePrice(PriceEntryBase priceEntryBase) { DateTime now = DateTime.Now; decimal price = priceEntryBase.NetEarn; decimal totalPrice = price; int totalCount = PriceList.Count; List <decimal> window = new List <decimal> { price }; decimal windowedPrice = price; int windowedCount = 0; bool outlier = false; if (!PriceList.ContainsKey(priceEntryBase)) { PriceList.Add(priceEntryBase, new List <PriceStat>()); } foreach (PriceStat stat in PriceList[priceEntryBase]) { decimal historicPrice = stat.CurrentPrice; totalPrice += historicPrice; if (stat.Time == now) { return; } if (stat.Time >= now - _statWindow) { window.Add(historicPrice); windowedPrice += historicPrice; windowedCount++; } } decimal totalAveragePrice = totalPrice / (totalCount + 1); decimal windowedAveragePrice = windowedPrice / (windowedCount + 1); if (windowedCount >= 10) // Makes sure at least ten entries are in there { window.Sort(); if (_iqrMultiplier > 0) { int iqrIndex = (int)Math.Truncate(window.Count * 0.75); decimal iqr = window[iqrIndex] - window[window.Count - iqrIndex]; outlier = price > windowedAveragePrice + (_iqrMultiplier * iqr); } else { // If the IQR multiplier is negative or zero, // it'll try to use percentiles for outlierdetection // Not advised! Will kill off trending profits, iqr-multiplying is preferable int outlierIndex = (int)Math.Truncate(window.Count * _percentile); decimal[] outliers = { window[outlierIndex], window[window.Count - outlierIndex] }; outlier = price > outliers.Max(); } } PriceStat priceStat = new PriceStat { Time = now, CurrentPrice = price, TotalAveragePrice = totalAveragePrice, WindowedAveragePrice = windowedAveragePrice, Outlier = outlier }; priceEntryBase.Outlier = outlier; priceEntryBase.NetAverage = windowedAveragePrice; PriceList[priceEntryBase].Add(priceStat); }
public void RequestStart(int id, bool isMinimizedToTray = false) { PriceEntryBase entry = _priceEntries.Single(o => o.Id == id); StartMiner(entry, isMinimizedToTray); }
private void StartMiner(PriceEntryBase entry, bool isMinimizedToTray = false) { _nextRun = null; _nextRunFromTime = null; _currentRunning = entry; _startMining = DateTime.Now; _stoppedMining = null; _process = new Process(); if (_donationMiningMode == MiningModeEnum.Donation) { if (!string.IsNullOrWhiteSpace(entry.DonationFolder)) { _process.StartInfo.WorkingDirectory = entry.DonationFolder; } _process.StartInfo.FileName = string.IsNullOrWhiteSpace(entry.DonationFolder) ? entry.DonationCommand : string.Format(@"{0}\{1}", entry.DonationFolder, entry.DonationCommand); _process.StartInfo.Arguments = entry.DonationArguments; } else { if (!string.IsNullOrWhiteSpace(entry.Folder)) { _process.StartInfo.WorkingDirectory = entry.Folder; } _process.StartInfo.FileName = string.IsNullOrWhiteSpace(entry.Folder) ? entry.Command : string.Format(@"{0}\{1}", entry.Folder, entry.Command); _process.StartInfo.Arguments = entry.Arguments; } WriteConsole( string.Format("Starting {0} {1} with {2} {3}", _currentRunning.ServicePrint, _currentRunning.Name, _process.StartInfo.FileName, _process.StartInfo.Arguments), true); if (!string.IsNullOrWhiteSpace(_process.StartInfo.WorkingDirectory) && !Directory.Exists(_process.StartInfo.WorkingDirectory)) { entry.DeadTime = DateTime.Now; string message = string.Format("Path '{0}' does not exist.", _process.StartInfo.WorkingDirectory); _process = null; WriteConsole(message, true); throw new ArgumentException(message); } if (!string.IsNullOrWhiteSpace(_process.StartInfo.FileName) && !File.Exists(_process.StartInfo.FileName)) { entry.DeadTime = DateTime.Now; string message = string.Format("File '{0}' does not exist.", _process.StartInfo.FileName); _process = null; WriteConsole(message, true); throw new ArgumentException(message); } if (entry.UseWindow) { _process.StartInfo.WindowStyle = (isMinimizedToTray && TrayMode == 2) ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Minimized; _process.Start(); Thread.Sleep(100); try { ProcessUtil.SetWindowTitle(_process, string.Format("{0} {1} Miner", entry.ServicePrint, entry.Name)); } catch (Exception ex) { ErrorLogger.Log(ex); } if (isMinimizedToTray && TrayMode == 1) { HideMinerWindow(); } } else { _process.StartInfo.RedirectStandardOutput = true; _process.StartInfo.RedirectStandardError = true; _process.EnableRaisingEvents = true; _process.StartInfo.CreateNoWindow = true; _process.StartInfo.UseShellExecute = false; _process.ErrorDataReceived += ProcessConsoleOutput; _process.OutputDataReceived += ProcessConsoleOutput; _process.Start(); _process.BeginOutputReadLine(); _process.BeginErrorReadLine(); } ProcessPriorityClass processPriority; if (entry.Priority != "Normal" && entry.Priority != string.Empty && Enum.TryParse(entry.Priority, out processPriority)) { // Defaults to Normal, other possible values are Idle, BelowNormal, // AboveNormal, High & RealTime. ccminer <3 RealTime // Note 1: Realtime by minercontrol is only possible when given administrator privileges to minercontrol // Note 2: --cpu-priority by ccminer overrides minercontrols priority // Note 3: When giving administrator privileges to minercontrol and setting the priority by minercontrol to // something DIFFERENT than what's used by --cpu-priority by ccminer, then your whole system locks up _process.PriorityClass = processPriority; } if (entry.Affinity > 0) { // Just like with start /affinity, you can use 1 for first core, 2 for second core, 4 for third core, etc _process.ProcessorAffinity = (IntPtr)entry.Affinity; } _startMining = DateTime.Now; _donationMiningMode = MiningMode; entry.UpdateStatus(); LogActivity(_donationMiningMode == MiningModeEnum.Donation ? "DonationStart" : "Start"); }
private void MPOSSpeed(object RawData) { if (RawData != null) { var hashrate = 0f; var rejected = 0f; JObject data = (JObject)RawData; JToken db = data["getdashboarddata"]; JToken shares = db["data"]["personal"]["shares"]; JToken ExRate = db["data"]["pool"]["price"]; JToken tag = db["data"]["pool"]["info"]["currency"]; hashrate = (float)db["data"]["personal"]["hashrate"]; rejected = hashrate * (float)shares["invalid_percent"] / 100; PriceEntryBase entry = GetEntryTag(tag.ToString()); if (entry != null && hashrate > 0) { float m = 1000; switch (ServiceName) { case "Suprnova": if (entry.AlgoName.ToLower().StartsWith("cryptonight") || entry.AlgoName.ToLower().StartsWith("lbry")) { m = m / 1000; } if (entry.AlgoName.ToLower().StartsWith("equihash")) { m = m / 1000000; } break; case "Dwarfpool": if (entry.AlgoName.ToLower().StartsWith("equihash")) { m = m / 1000; } break; case "MiningPoolHub": if (entry.AlgoName.ToLower().StartsWith("blake") || entry.AlgoName.ToLower().StartsWith("decred")) { m = m * 1000; } if (entry.AlgoName.ToLower().StartsWith("equihash")) { m = m / 1000000; } if (entry.AlgoName.ToLower().StartsWith("cryptonight")) { m = m / 1000; } break; default: if (entry.AlgoName.ToLower().StartsWith("decred") || entry.AlgoName.ToLower().StartsWith("lbry")) { m = m * 1000; } if (entry.AlgoName.ToLower().StartsWith("equihash")) { m = m / 1000000; } break; } entry.AcceptSpeed = hashrate.ExtractDecimal() * m.ExtractDecimal(); entry.RejectSpeed = rejected.ExtractDecimal() * m.ExtractDecimal(); } } }
public bool IsBadEntry(PriceEntryBase priceEntry) { return(priceEntry.BelowMinPrice || priceEntry.Banned || priceEntry.IsDead); }
private void MPOSSpeedWorker(object RawData) { if (RawData != null) { JObject data = (JObject)RawData; JToken db = data["getuserworkers"]; JToken value = db["data"]; JToken status = data["getuserworkers"]["version"]; PriceEntryBase entry = GetEntryCoin(status.ToString()); if (entry != null) { foreach (var item in value.Children()) { var w = item["username"].ToString(); var s = (float)item["hashrate"]; float m = 1; if (entry.AlgoName.ToLower().StartsWith("equihash")) { s = s / 1000000; } switch (ServiceName) { case "CoinMine": if (entry.AlgoName.ToLower().StartsWith("equihash")) { m = m * 1000; } break; case "Dwarfpool": if (entry.AlgoName.ToLower().StartsWith("equihash")) { m = m / 1000; } break; case "Suprnova": if (entry.Tag.ToLower().StartsWith("zec")) { m = m * 1000; } break; case "AikaPool": if (entry.Tag.ToLower().StartsWith("kmd") || entry.Tag.ToLower().StartsWith("zdash")) { m = m / 1000; } break; case "MiningPoolHub": if (entry.AlgoName.ToLower().StartsWith("blake") || entry.AlgoName.ToLower().StartsWith("decred")) { m = m * 1000000; } if (entry.AlgoName.ToLower().StartsWith("equihash")) { m = m * 1000; } break; default: if (entry.AlgoName.ToLower().StartsWith("equihash")) { m = m * 1000; } break; } if (w.ToString().ToLower() == _account.ToString().ToLower() + "." + _worker.ToString().ToLower() && s > 0) { entry.AcSpWrk = s.ExtractDecimal() * m.ExtractDecimal(); AverageSpeed(entry); } } } } }