static NHSmaData() { _currentPayingRates = new Dictionary <AlgorithmType, double>(); _stableAlgorithms = new HashSet <AlgorithmType>(); var cacheDict = InternalConfigs.ReadFileSettings <Dictionary <AlgorithmType, double> >(CachedFile); // _recentPaying = new Dictionary<AlgorithmType, List<double>>(); foreach (AlgorithmType algo in Enum.GetValues(typeof(AlgorithmType))) { if (algo >= 0) { var paying = 0d; if (cacheDict?.TryGetValue(algo, out paying) ?? false) { HasData = true; } if (BuildOptions.FORCE_MINING || BuildOptions.FORCE_PROFITABLE) { paying = 10000; } _currentPayingRates[algo] = paying; } } }
static SupportedAlgorithmsFilter() { // new platform #if (TESTNET || TESTNETDEV || PRODUCTION_NEW) _filteredAlgorithms.Add(new List <AlgorithmType> { AlgorithmType.MTP }); #else // old platform _filteredAlgorithms.Add(new List <AlgorithmType> { AlgorithmType.GrinCuckarood29 }); _filteredAlgorithms.Add(new List <AlgorithmType> { AlgorithmType.BeamV2 }); #endif var internalSettings = InternalConfigs.ReadFileSettings <List <List <AlgorithmType> > >(_internalSettingFilePath); if (internalSettings != null) { _filteredAlgorithms = internalSettings; } else { InternalConfigs.WriteFileSettings(_internalSettingFilePath, _filteredAlgorithms); } }
// Public for tests only public static void Initialize() { _currentPayingRates = new Dictionary <AlgorithmType, double>(); _stableAlgorithms = new HashSet <AlgorithmType>(); var cacheDict = InternalConfigs.ReadFileSettings <Dictionary <AlgorithmType, double> >(CachedFile); // _recentPaying = new Dictionary<AlgorithmType, List<double>>(); foreach (AlgorithmType algo in Enum.GetValues(typeof(AlgorithmType))) { if (algo >= 0) { var paying = 0d; if (cacheDict?.TryGetValue(algo, out paying) ?? false) { HasData = true; } #if FILLSMA paying = 1; #endif _currentPayingRates[algo] = paying; } } Initialized = true; }
public static void InitializeConfig() { TryMigrate(); // init defaults GeneralConfig.SetDefaults(); GeneralConfig.hwid = ApplicationStateManager.RigID; // load file if it exist var fromFile = InternalConfigs.ReadFileSettings <GeneralConfig>(GeneralConfigPath); if (fromFile != null) { var asmVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; if (fromFile.ConfigFileVersion != null && asmVersion.CompareTo(fromFile.ConfigFileVersion) != 0) { Logger.Info(Tag, "Config file is differs from version of NiceHashMiner... Creating backup archive"); CreateBackupArchive(fromFile.ConfigFileVersion); } if (fromFile.ConfigFileVersion != null) { // set config loaded from file _isGeneralConfigFileInit = true; GeneralConfig = fromFile; GeneralConfig.FixSettingBounds(); } else { Logger.Info(Tag, "Loaded Config file no version detected falling back to defaults."); } } else { GeneralConfigFileCommit(); } }
internal static async Task RestoreMiningState() { var devicesRestoreStates = InternalConfigs.ReadFileSettings <Dictionary <string, DeviceRestoreState> >(_miningStateFilePath); bool oldPath = false; var miningStateFilePathOLD = Paths.RootPath("DeviceRestoreStates.json"); if (devicesRestoreStates == null) { // check the old path since older versions will save it there devicesRestoreStates = InternalConfigs.ReadFileSettings <Dictionary <string, DeviceRestoreState> >(miningStateFilePathOLD); oldPath = devicesRestoreStates != null; } if (devicesRestoreStates == null) { return; } try { File.Delete(oldPath ? miningStateFilePathOLD : _miningStateFilePath); } catch (Exception e) { var oldPathStr = oldPath ? "old path" : ""; Logger.Error("ApplicationStateManager.Mining", $"RestoreMiningState delete {oldPathStr} Exception: {e.Message}"); } // restore states var startTasks = devicesRestoreStates.Where(devStatePair => devStatePair.Value.ShouldStart()) .Select(devStatePair => AvailableDevices.GetDeviceWithUuid(devStatePair.Key)) .Where(dev => dev != null) .Select(StartDeviceTask) .ToArray(); // now attempt restart await Task.WhenAll(startTasks); }
public void InitInternals() { // set ethlargement path _ethlargementBinPath = EthlargementBinPath(); var pluginRoot = Path.Combine(Paths.MinerPluginsPath(), PluginUUID); var pluginRootIntenrals = Path.Combine(pluginRoot, "internals"); var supportedDevicesSettingsPath = Path.Combine(pluginRootIntenrals, "SupportedDevicesSettings.json"); var fileMinerOptionsPackage = InternalConfigs.ReadFileSettings <SupportedDevicesSettings>(supportedDevicesSettingsPath); if (fileMinerOptionsPackage != null && fileMinerOptionsPackage.UseUserSettings) { _supportedDevicesSettings = fileMinerOptionsPackage; } else { InternalConfigs.WriteFileSettings(supportedDevicesSettingsPath, _supportedDevicesSettings); } // Filter out supported ones var supportedDevicesNames = _supportedDevicesSettings.SupportedDeviceNames; if (supportedDevicesNames == null) { return; } Func <string, bool> isSupportedName = (string name) => supportedDevicesNames.Any(supportedPart => name.Contains(supportedPart)); var unsupportedDevicesUUIDs = _registeredSupportedDevices.Where(kvp => !isSupportedName(kvp.Value)).Select(kvp => kvp.Key).ToArray(); foreach (var removeKey in unsupportedDevicesUUIDs) { _registeredSupportedDevices.Remove(removeKey); } }
static FirewallRules() { var lastSaved = InternalConfigs.ReadFileSettings <List <string> >(_firewallRulesAddedFilePath); if (lastSaved != null) { _pluginsUUIDsWithVersions = lastSaved; } }
static AcceptedPlugins() { var file = InternalConfigs.ReadFileSettings <List <string> >(AcceptedPluginsPath); if (file != null) { AcceptedPluginUUIDs = file; } }
public static void InitializeConfig() { // init defaults GeneralConfig.SetDefaults(); ToSSetings.Instance.Hwid = ApplicationStateManager.RigID(); var asmVersion = new Version(Application.ProductVersion); // load file if it exist var fromFile = InternalConfigs.ReadFileSettings <GeneralConfig>(GeneralConfigPath); if (fromFile != null) { if (fromFile.ConfigFileVersion != null && asmVersion.CompareTo(fromFile.ConfigFileVersion) != 0) { IsVersionChanged = true; Logger.Info(Tag, "Config file differs from version of NiceHashMiner... Creating backup archive"); CreateBackupArchive(fromFile.ConfigFileVersion); if (RestoreBackupArchive(asmVersion))//check if we have backup version { fromFile = InternalConfigs.ReadFileSettings <GeneralConfig>(GeneralConfigPath); } } if (fromFile?.ConfigFileVersion != null) { GeneralConfig = fromFile; GeneralConfig.FixSettingBounds(); // TODO temp GeneralConfig.PropertyChanged += BalanceAndExchangeRates.Instance.GeneralConfig_PropertyChanged; } else { Logger.Info(Tag, "Loaded Config file no version detected falling back to defaults."); } } else { GeneralConfigFileCommit(); } //Init Blacklist plugins var blacklistFile = InternalConfigs.ReadFileSettings <BlacklistedPlugins>(BlacklistedPluginsPath); if (blacklistFile != null) { if (blacklistFile?.BlacklistedPluginUUIDs != null) { BlacklistedPlugins.Instance.BlacklistedPluginUUIDs = blacklistFile.BlacklistedPluginUUIDs; } } else { BlacklistPluginsCommit(); } }
static SupportedPluginsFilter() { string internalSettingFilePath = Paths.InternalsPath("SupportedPluginsFilter.json"); var internalSettings = InternalConfigs.ReadFileSettings <List <string> >(internalSettingFilePath); if (internalSettings != null) { _filteredPlugins = internalSettings; } else { InternalConfigs.WriteFileSettings(internalSettingFilePath, _filteredPlugins); } }
static GetValueOrErrorSettings() { var settingsPath = Paths.MinerPluginsPath("BrokenMinerPluginUUID", "settings.json"); var globalBenchmarkExceptions = InternalConfigs.ReadFileSettings <Dictionary <string, bool> >(settingsPath); if (globalBenchmarkExceptions != null) { _settings = globalBenchmarkExceptions; } else { InternalConfigs.WriteFileSettings(settingsPath, _settings); } }
static BenchmarkProcessSettings() { const string globalBenchmarkExceptionsPath = @"internals\GlobalBenchmarkExceptions.json"; var globalBenchmarkExceptions = InternalConfigs.ReadFileSettings <Dictionary <string, string> >(globalBenchmarkExceptionsPath); if (globalBenchmarkExceptions != null) { GlobalBenchmarkExceptions = globalBenchmarkExceptions; } else { InternalConfigs.WriteFileSettings(globalBenchmarkExceptionsPath, GlobalBenchmarkExceptions); } }
public static void InitDeviceSettings() { // create/init device configs foreach (var device in AvailableDevices.Devices) { var devSettingsPath = GetDeviceSettingsPath(device.Uuid); var currentConfig = InternalConfigs.ReadFileSettings <DeviceConfig>(devSettingsPath); if (currentConfig != null) { device.SetDeviceConfig(currentConfig); } } // save settings CommitBenchmarks(); }
static MinersBinsUrls() { string binsUrlSettings = Paths.RootPath("miner_bins_urls.json"); var fileSettings = InternalConfigs.ReadFileSettings <MinersBinsUrlsSettings>(binsUrlSettings); if (fileSettings != null && fileSettings.UseFileSettings && fileSettings.PluginsUrls != null) { _pluginsUrls = fileSettings.PluginsUrls; } else { InternalConfigs.WriteFileSettings(binsUrlSettings, new MinersBinsUrlsSettings { PluginsUrls = _pluginsUrls }); } }
static SupportedAlgorithmsFilter() { // TESTNET #if (TESTNET || TESTNETDEV || PRODUCTION_NEW) _filteredAlgorithms.Add(new List <AlgorithmType> { AlgorithmType.MTP }); #endif var internalSettings = InternalConfigs.ReadFileSettings <List <List <AlgorithmType> > >(_internalSettingFilePath); if (internalSettings != null) { _filteredAlgorithms = internalSettings; } else { InternalConfigs.WriteFileSettings(_internalSettingFilePath, _filteredAlgorithms); } }
static BlacklistedPlugins() { var blacklistFile = InternalConfigs.ReadFileSettings <List <string> >(BlacklistedPluginsPath); if (blacklistFile != null) { BlacklistedPluginUUIDs = blacklistFile; } else { var blacklistFileOld = InternalConfigs.ReadFileSettings <LegacyFileClass>(BlacklistedPluginsPath); if (blacklistFileOld?.BlacklistedPluginUUIDs != null) { BlacklistedPluginUUIDs = blacklistFileOld.BlacklistedPluginUUIDs; } } // commit to make sure legacy file is overwritten CommitToFile(); }
public static void InitializeConfig() { // init defaults GeneralConfig.SetDefaults(); GeneralConfig.hwid = ApplicationStateManager.RigID; var asmVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; // load file if it exist var fromFile = InternalConfigs.ReadFileSettings <GeneralConfig>(GeneralConfigPath); if (fromFile != null) { if (fromFile.ConfigFileVersion != null && asmVersion.CompareTo(fromFile.ConfigFileVersion) != 0) { IsVersionChanged = true; Logger.Info(Tag, "Config file differs from version of NiceHashMiner... Creating backup archive"); CreateBackupArchive(fromFile.ConfigFileVersion); if (RestoreBackupArchive(asmVersion))//check if we have backup version { fromFile = InternalConfigs.ReadFileSettings <GeneralConfig>(GeneralConfigPath); } } if (fromFile?.ConfigFileVersion != null) { // set config loaded from file _isGeneralConfigFileInit = true; GeneralConfig = fromFile; GeneralConfig.FixSettingBounds(); } else { Logger.Info(Tag, "Loaded Config file no version detected falling back to defaults."); } } else { GeneralConfigFileCommit(); } #warning "DELETE this after 1.9.2.18" #region MIGRATE plugin UUIDs var findReplace = new Dictionary <string, string> { { "\"PluginUUID\": \"BMiner\",", "\"PluginUUID\": \"e5fbd330-7235-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"CCMinerTpruvot\",", "\"PluginUUID\": \"2257f160-7236-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"ClaymoreDual\",", "\"PluginUUID\": \"70984aa0-7236-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"cpuminer-opt\",", "\"PluginUUID\": \"92fceb00-7236-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"CryptoDredge\",", "\"PluginUUID\": \"d9c2e620-7236-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"Ethlargement\",", "\"PluginUUID\": \"efd40691-618c-491a-b328-e7e020bda7a3\"," }, { "\"PluginUUID\": \"Ewbf\",", "\"PluginUUID\": \"f7d5dfa0-7236-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"ExamplePlugin\",", "\"PluginUUID\": \"455c4d98-a45d-45d6-98ca-499ce866b2c7\"," }, { "\"PluginUUID\": \"GMinerCuda9.0+\",", "\"PluginUUID\": \"1b7019d0-7237-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"LolMinerBeam\",", "\"PluginUUID\": \"435f0820-7237-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"MiniZ\",", "\"PluginUUID\": \"59bba2c0-b1ef-11e9-8e4e-bb1e2c6e76b4\"," }, { "\"PluginUUID\": \"NanoMiner\",", "\"PluginUUID\": \"a841b4b0-ae17-11e9-8e4e-bb1e2c6e76b4\"," }, { "\"PluginUUID\": \"NBMiner\",", "\"PluginUUID\": \"6c07f7a0-7237-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"Phoenix\",", "\"PluginUUID\": \"f5d4a470-e360-11e9-a914-497feefbdfc8\"," }, { "\"PluginUUID\": \"SGminerAvemore\",", "\"PluginUUID\": \"bc95fd70-e361-11e9-a914-497feefbdfc8\"," }, { "\"PluginUUID\": \"SRBMiner\",", "\"PluginUUID\": \"85f507c0-b2ba-11e9-8e4e-bb1e2c6e76b4\"," }, { "\"PluginUUID\": \"TeamRedMiner\",", "\"PluginUUID\": \"abc3e2a0-7237-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"TRex\",", "\"PluginUUID\": \"d47d9b00-7237-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"TTMiner\",", "\"PluginUUID\": \"f1945a30-7237-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"WildRig\",", "\"PluginUUID\": \"2edd8080-9cb6-11e9-a6b8-09e27549d5bb\"," }, { "\"PluginUUID\": \"XMRig\",", "\"PluginUUID\": \"1046ea50-c261-11e9-8e4e-bb1e2c6e76b4\"," }, { "\"PluginUUID\": \"XmrStak\",", "\"PluginUUID\": \"3d4e56b0-7238-11e9-b20c-f9f12eb6d835\"," }, { "\"PluginUUID\": \"ZEnemy\",", "\"PluginUUID\": \"5532d300-7238-11e9-b20c-f9f12eb6d835\"," }, }; try { var deviceConfigs = Directory.GetFiles(Paths.ConfigsPath(), "device_settings_*.json", SearchOption.TopDirectoryOnly); foreach (var devConfigPath in deviceConfigs) { try { var content = File.ReadAllText(devConfigPath); var containsNameUUIDs = false; foreach (var key in findReplace.Keys) { if (content.Contains(key)) { containsNameUUIDs = true; break; } } if (!containsNameUUIDs) { continue; } foreach (var kvp in findReplace) { content = content.Replace(kvp.Key, kvp.Value); } File.WriteAllText(devConfigPath, content); } catch {} } } catch {} #endregion MIGRATE plugin UUIDs }