Example #1
0
 public static void InitializeConfig()
 {
     // init defaults
     ConfigManager.GeneralConfig.SetDefaults();
     ConfigManager.GeneralConfig.hwid = Helpers.GetCpuID();
     // if exists load file
     GeneralConfig fromFile = null;
     if(GeneralConfigFile.IsFileExists()) {
         fromFile = GeneralConfigFile.ReadFile();
     }
     // just in case
     if (fromFile != null) {
         // set config loaded from file
         IsGeneralConfigFileInit = true;
         ConfigManager.GeneralConfig = fromFile;
         if (ConfigManager.GeneralConfig.ConfigFileVersion == null
             || ConfigManager.GeneralConfig.ConfigFileVersion.CompareTo(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version) != 0) {
             if (ConfigManager.GeneralConfig.ConfigFileVersion == null) {
                 Helpers.ConsolePrint(TAG, "Loaded Config file no version detected falling back to defaults.");
                 ConfigManager.GeneralConfig.SetDefaults();
             }
             Helpers.ConsolePrint(TAG, "Config file is from an older version of NiceHashMiner..");
             IsNewVersion = true;
             GeneralConfigFile.CreateBackup();
         }
         ConfigManager.GeneralConfig.FixSettingBounds();
         // check vars
         hwidLoadFromFile = true;
         hwidOK = Helpers.GetCpuID() == ConfigManager.GeneralConfig.hwid;
     } else {
         GeneralConfigFileCommit();
     }
 }
Example #2
0
 public static void RestoreBackup()
 {
     // restore general
     GeneralConfig = GeneralConfigBackup;
     if (GeneralConfig.LastDevicesSettup != null) {
         foreach (var CDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) {
             foreach (var conf in GeneralConfig.LastDevicesSettup) {
                 CDev.SetFromComputeDeviceConfig(conf);
             }
         }
     }
     // restore benchmarks
     foreach (var CDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) {
         if (BenchmarkConfigsBackup != null && BenchmarkConfigsBackup.ContainsKey(CDev.UUID)) {
             CDev.SetAlgorithmDeviceConfig(BenchmarkConfigsBackup[CDev.UUID]);
         }
     }
 }
Example #3
0
 public static void CreateBackup()
 {
     GeneralConfigBackup = MemoryHelper.DeepClone(ConfigManager.GeneralConfig);
     BenchmarkConfigsBackup = new Dictionary<string, DeviceBenchmarkConfig>();
     foreach (var CDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) {
         BenchmarkConfigsBackup[CDev.UUID] = CDev.GetAlgorithmDeviceConfig();
     }
 }