Пример #1
0
        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();
            }
        }
Пример #2
0
        public void AfterDeviceQueryInitialization()
        {
            GeneralConfig.AfterDeviceQueryInitialization();
            LoadBenchmarks();

            SetDeviceBenchmarkReferences();



            // check ethminers and remove from settings if no device supports it in config
            foreach (var config in BenchmarkConfigs)
            {
                bool removeDagger = true;
                var  cDev         = ComputeDevice.GetDeviceWithUUID(config.Value.DeviceUUID);
                if (cDev != null)
                {
                    // if only one dev ing roup supports terminate
                    if (cDev.IsEtherumCapale)
                    {
                        removeDagger = false;
                        break;
                    }
                }
                if (removeDagger)
                {
                    config.Value.AlgorithmSettings.Remove(AlgorithmType.DaggerHashimoto);
                }
            }

            CommitBenchmarks();
        }
 public static void CreateBackup()
 {
     _generalConfigBackup    = MemoryHelper.DeepClone(GeneralConfig);
     _benchmarkConfigsBackup = new Dictionary <string, DeviceBenchmarkConfig>();
     foreach (var cDev in AvailableDevices.Devices)
     {
         _benchmarkConfigsBackup[cDev.Uuid] = cDev.GetAlgorithmDeviceConfig();
     }
 }
 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();
     }
 }
Пример #5
0
        // TODO remove this eventually, keep for now
        public void LegacyConfigMigration()
        {
            // CHECK LEGACY config, migration logic
            if (Config.ConfigFileExist())
            {
                Helpers.ConsolePrint(TAG, "Migrating LEGACY config");
                Config.InitializeConfig();

                // migrate relevant data
                GeneralConfig.Language        = (LanguageType)Config.ConfigData.Language;
                GeneralConfig.BitcoinAddress  = Config.ConfigData.BitcoinAddress;
                GeneralConfig.WorkerName      = Config.ConfigData.WorkerName;
                GeneralConfig.ServiceLocation = Config.ConfigData.ServiceLocation;
                //GeneralConfig.LessThreads = Config.ConfigData.LessThreads;
                //GeneralConfig.Groups = new Group[0] = Config.ConfigData.Groups = new Group[0];
                GeneralConfig.DebugConsole      = Config.ConfigData.DebugConsole;
                GeneralConfig.HideMiningWindows = Config.ConfigData.HideMiningWindows;
                GeneralConfig.MinimizeToTray    = Config.ConfigData.MinimizeToTray;
                //GeneralConfig.AutoStartMining = Config.ConfigData.AutoStartMining;
                GeneralConfig.DeviceDetection.DisableDetectionNVidia5X = Config.ConfigData.DisableDetectionNVidia5X;
                GeneralConfig.DeviceDetection.DisableDetectionNVidia3X = Config.ConfigData.DisableDetectionNVidia3X;
                GeneralConfig.DeviceDetection.DisableDetectionNVidia2X = Config.ConfigData.DisableDetectionNVidia2X;
                GeneralConfig.DeviceDetection.DisableDetectionAMD      = Config.ConfigData.DisableDetectionAMD;
                //GeneralConfig.DisableAMDTempControl = Config.ConfigData.DisableAMDTempControl;
                GeneralConfig.AutoScaleBTCValues           = Config.ConfigData.AutoScaleBTCValues;
                GeneralConfig.StartMiningWhenIdle          = Config.ConfigData.StartMiningWhenIdle;
                GeneralConfig.LogToFile                    = Config.ConfigData.LogToFile;
                GeneralConfig.LogMaxFileSize               = Config.ConfigData.LogMaxFileSize;
                GeneralConfig.ShowDriverVersionWarning     = Config.ConfigData.ShowDriverVersionWarning;
                GeneralConfig.DisableWindowsErrorReporting = Config.ConfigData.DisableWindowsErrorReporting;
                //GeneralConfig.UseNewSettingsPage = Config.ConfigData.UseNewSettingsPage;
                GeneralConfig.NVIDIAP0State              = Config.ConfigData.NVIDIAP0State;
                GeneralConfig.MinerRestartDelayMS        = Config.ConfigData.MinerRestartDelayMS;
                GeneralConfig.ethminerDefaultBlockHeight = Config.ConfigData.ethminerDefaultBlockHeight;
                //GeneralConfig.MinerAPIGraceSeconds = Config.ConfigData.MinerAPIGraceSeconds;
                //GeneralConfig.MinerAPIGraceSecondsAMD = Config.ConfigData.MinerAPIGraceSecondsAMD;
                GeneralConfig.SwitchMinSecondsFixed   = Config.ConfigData.SwitchMinSecondsFixed;
                GeneralConfig.SwitchMinSecondsDynamic = Config.ConfigData.SwitchMinSecondsDynamic;
                GeneralConfig.SwitchMinSecondsAMD     = Config.ConfigData.SwitchMinSecondsAMD;
                GeneralConfig.MinIdleSeconds          = Config.ConfigData.MinIdleSeconds;
                GeneralConfig.DisplayCurrency         = Config.ConfigData.DisplayCurrency;

                // save migration
                GeneralConfig.Commit();

                Config.DeleteLegacy();
            }
        }
        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;
                ConfigManager.GeneralConfig.SetMyDefaults();
            }
            else
            {
                ConfigManager.GeneralConfig.SetMyDefaults();
                GeneralConfigFileCommit();
            }
        }
        public static void InitializeConfig()
        {
            // init defaults
            GeneralConfig.SetDefaults();
            GeneralConfig.hwid = WindowsManagementObjectSearcher.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;
                GeneralConfig            = fromFile;
                if (GeneralConfig.ConfigFileVersion == null ||
                    GeneralConfig.ConfigFileVersion.CompareTo(System.Reflection.Assembly.GetExecutingAssembly()
                                                              .GetName().Version) != 0)
                {
                    if (GeneralConfig.ConfigFileVersion == null)
                    {
                        Helpers.ConsolePrint(Tag, "Loaded Config file no version detected falling back to defaults.");
                        GeneralConfig.SetDefaults();
                    }
                    Helpers.ConsolePrint(Tag, "Config file is from an older version of NiceHashMiner..");
                    _isNewVersion = true;
                    GeneralConfigFile.CreateBackup();
                }
                GeneralConfig.FixSettingBounds();
            }
            else
            {
                GeneralConfigFileCommit();
            }
        }
 public static void RestoreBackup()
 {
     // restore general
     GeneralConfig = _generalConfigBackup;
     if (GeneralConfig.LastDevicesSettup != null)
     {
         foreach (var cDev in AvailableDevices.Devices)
         {
             foreach (var conf in GeneralConfig.LastDevicesSettup)
             {
                 cDev.SetFromComputeDeviceConfig(conf);
             }
         }
     }
     // restore benchmarks
     foreach (var cDev in AvailableDevices.Devices)
     {
         if (_benchmarkConfigsBackup != null && _benchmarkConfigsBackup.ContainsKey(cDev.Uuid))
         {
             cDev.SetAlgorithmDeviceConfig(_benchmarkConfigsBackup[cDev.Uuid]);
         }
     }
 }
 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]);
         }
     }
 }
Пример #10
0
 // constructor has references don't delete it
 protected ConfigManager()
 {
     TAG              = this.GetType().Name;
     GeneralConfig    = new GeneralConfig(true);
     BenchmarkConfigs = new Dictionary <string, DeviceBenchmarkConfig>();
 }