Ejemplo n.º 1
0
        // TODO add ELP internal configs here
        public void InitInternals()
        {
            var pluginRoot = Path.Combine(Paths.MinerPluginsPath(), PluginUUID);

            var readFromFileEnvSysVars = InternalConfigs.InitMinerSystemEnvironmentVariablesSettings(pluginRoot, _minerSystemEnvironmentVariables);

            if (readFromFileEnvSysVars != null)
            {
                _minerSystemEnvironmentVariables = readFromFileEnvSysVars;
            }

            var fileMinerOptionsPackage = InternalConfigs.InitInternalsHelper(pluginRoot, _minerOptionsPackage);

            if (fileMinerOptionsPackage != null)
            {
                _minerOptionsPackage = fileMinerOptionsPackage;
            }

            var fileMinerReservedPorts = InternalConfigs.InitMinerReservedPorts(pluginRoot, _minerReservedApiPorts);

            if (fileMinerReservedPorts != null)
            {
                _minerReservedApiPorts = fileMinerReservedPorts;
            }

            var fileMinerBenchmarkTimeSetting = InternalConfigs.InitMinerBenchmarkTimeSettings(pluginRoot, _minerBenchmarkTimeSettings);

            if (fileMinerBenchmarkTimeSetting != null)
            {
                _minerBenchmarkTimeSettings = fileMinerBenchmarkTimeSetting;
            }
        }
Ejemplo n.º 2
0
        public virtual void InitInternals()
        {
            var pluginRoot = Path.Combine(Paths.MinerPluginsPath(), PluginUUID);

            var readFromFileEnvSysVars = InternalConfigs.InitMinerSystemEnvironmentVariablesSettings(pluginRoot, MinerSystemEnvironmentVariables);

            if (readFromFileEnvSysVars != null)
            {
                MinerSystemEnvironmentVariables = readFromFileEnvSysVars;
            }

            var fileMinerOptionsPackage = InternalConfigs.InitInternalsHelper(pluginRoot, MinerOptionsPackage);

            if (fileMinerOptionsPackage != null)
            {
                MinerOptionsPackage = fileMinerOptionsPackage;
            }

            var fileMinerReservedPorts = InternalConfigs.InitMinerReservedPorts(pluginRoot, MinerReservedApiPorts);

            if (fileMinerReservedPorts != null)
            {
                MinerReservedApiPorts = fileMinerReservedPorts;
            }

            var fileMinerApiMaxTimeoutSetting = InternalConfigs.InitMinerApiMaxTimeoutSetting(pluginRoot, GetApiMaxTimeoutConfig);

            if (fileMinerApiMaxTimeoutSetting != null)
            {
                GetApiMaxTimeoutConfig = fileMinerApiMaxTimeoutSetting;
            }

            var fileMinerBenchmarkTimeSetting = InternalConfigs.InitMinerBenchmarkTimeSettings(pluginRoot, MinerBenchmarkTimeSettings);

            if (fileMinerBenchmarkTimeSetting != null)
            {
                MinerBenchmarkTimeSettings = fileMinerBenchmarkTimeSetting;
            }

            var fileMinersBinsUrlsSettings = InternalConfigs.InitInternalSetting(pluginRoot, MinersBinsUrlsSettings, "MinersBinsUrlsSettings.json");

            if (fileMinersBinsUrlsSettings != null)
            {
                MinersBinsUrlsSettings = fileMinersBinsUrlsSettings;
            }
        }
Ejemplo n.º 3
0
        // these here are slightly different
        #region Internal settings
        public void InitInternals()
        {
            var pluginRoot = Path.Combine(Paths.MinerPluginsPath(), PluginUUID);
            var fileMinerOptionsPackage = InternalConfigs.InitInternalsHelper(pluginRoot, _minerOptionsPackage);

            if (fileMinerOptionsPackage != null)
            {
                _minerOptionsPackage = fileMinerOptionsPackage;
            }

            var readFromFileEnvSysVars = InternalConfigs.InitMinerSystemEnvironmentVariablesSettings(pluginRoot, _minerSystemEnvironmentVariables);

            if (readFromFileEnvSysVars != null)
            {
                _minerSystemEnvironmentVariables = readFromFileEnvSysVars;
            }

            var fileMinerReservedPorts = InternalConfigs.InitMinerReservedPorts(pluginRoot, _minerReservedApiPorts);

            if (fileMinerReservedPorts != null)
            {
                _minerReservedApiPorts = fileMinerReservedPorts;
            }

            var fileMinerApiMaxTimeoutSetting = InternalConfigs.InitMinerApiMaxTimeoutSetting(pluginRoot, _getApiMaxTimeoutConfig);

            if (fileMinerApiMaxTimeoutSetting != null)
            {
                _getApiMaxTimeoutConfig = fileMinerApiMaxTimeoutSetting;
            }

            var fileMinerBenchmarkTimeSetting = InternalConfigs.InitMinerBenchmarkTimeSettings(pluginRoot, _minerBenchmarkTimeSettings);

            if (fileMinerBenchmarkTimeSetting != null)
            {
                _minerBenchmarkTimeSettings = fileMinerBenchmarkTimeSetting;
            }

            var minerConfigPath = GetMinerConfigsRoot();

            if (!Directory.Exists(minerConfigPath))
            {
                return;                                     // no settings
            }
            var configFiles           = Directory.GetFiles(minerConfigPath, "cached_*.json");
            var registeredDeviceTypes = _registeredDeviceUUIDTypes.Select(kvp => kvp.Value).Distinct();

            foreach (var deviceType in registeredDeviceTypes)
            {
                var uuids = _registeredDeviceUUIDTypes.Where(kvp => kvp.Value == deviceType).Select(kvp => kvp.Key);
                foreach (var algorithm in _registeredAlgorithmTypes)
                {
                    var cachedConfig     = $"{algorithm.ToString()}_{deviceType.ToString()}";
                    var cachedConfigPath = configFiles.Where(path => path.Contains(cachedConfig)).FirstOrDefault();
                    if (string.IsNullOrEmpty(cachedConfigPath))
                    {
                        continue;
                    }

                    var cachedConfigContent = File.ReadAllText(cachedConfigPath);
                    try
                    {
                        switch (deviceType)
                        {
                        case DeviceType.CPU:
                            var cpuConfig = JsonConvert.DeserializeObject <CachedCpuSettings>(cachedConfigContent);
                            var isCpuSame = uuids.Except(cpuConfig.DeviceUUIDs).Count() == 0;
                            if (isCpuSame)
                            {
                                SetCpuConfig(algorithm, cpuConfig.CachedConfig);
                            }
                            break;

                        case DeviceType.AMD:
                            var amdConfig = JsonConvert.DeserializeObject <CachedAmdSettings>(cachedConfigContent);
                            var isAmdSame = uuids.Except(amdConfig.DeviceUUIDs).Count() == 0;
                            if (isAmdSame)
                            {
                                SetAmdConfig(algorithm, amdConfig.CachedConfig);
                            }
                            break;

                        case DeviceType.NVIDIA:
                            var nvidiaConfig = JsonConvert.DeserializeObject <CachedNvidiaSettings>(cachedConfigContent);
                            var isNvidiaSame = uuids.Except(nvidiaConfig.DeviceUUIDs).Count() == 0;
                            if (isNvidiaSame)
                            {
                                SetNvidiaConfig(algorithm, nvidiaConfig.CachedConfig);
                            }
                            break;
                        }
                    }
                    catch (Exception)
                    { }
                }
            }
        }