Example #1
0
        // TODO document/add docs
        public static TimeSpan ParseMaxTimeout(TimeSpan defaultMaxTimeout, MinerApiMaxTimeoutSetting config, IEnumerable <MiningPair> miningPairs)
        {
            if (config?.UseUserSettings ?? false)
            {
                // TimeoutPerDeviceType has #1 priority
                var pairDeviceTypeTimeout = config.TimeoutPerDeviceType;
                var deviceTypes           = miningPairs.Select(mp => mp.Device.DeviceType);
                foreach (var deviceType in _deviceTypePriority)
                {
                    if (pairDeviceTypeTimeout != null && pairDeviceTypeTimeout.ContainsKey(deviceType) && deviceTypes.Contains(deviceType))
                    {
                        return(pairDeviceTypeTimeout[deviceType]);
                    }
                }
                // TimeoutPerAlgorithm has #2 priority
                var pairAlgorithmTimeout = config.TimeoutPerAlgorithm;
                var algorithmName        = miningPairs.FirstOrDefault()?.Algorithm?.AlgorithmName ?? "";
                if (pairAlgorithmTimeout != null && !string.IsNullOrEmpty(algorithmName) && pairAlgorithmTimeout.ContainsKey(algorithmName))
                {
                    return(pairAlgorithmTimeout[algorithmName]);
                }

                return(config.GeneralTimeout);
            }
            return(defaultMaxTimeout);
        }
        // TODO document/add docs
        public static TimeSpan ParseMaxTimeout(TimeSpan defaultMaxTimeout, MinerApiMaxTimeoutSetting config, IEnumerable <MiningPair> miningPairs)
        {
            if (config?.UseUserSettings ?? false)
            {
                // TimeoutPerDeviceType has #1 priority
                var pairDeviceTypeTimeout = config.TimeoutPerDeviceType;
                var deviceTypes           = miningPairs.Select(mp => mp.Device.DeviceType);
                if (pairDeviceTypeTimeout != null)
                {
                    var relevantTimeouts = pairDeviceTypeTimeout.Where(kvp => deviceTypes.Contains(kvp.Key))
                                           .OrderBy(kvp => kvp.Value);
                    if (relevantTimeouts.Count() > 0)
                    {
                        return(relevantTimeouts.First().Value);
                    }
                }
                // TimeoutPerAlgorithm has #2 priority
                var pairAlgorithmTimeout = config.TimeoutPerAlgorithm;
                var algorithmName        = miningPairs.FirstOrDefault()?.Algorithm?.AlgorithmName ?? "";
                if (pairAlgorithmTimeout != null && !string.IsNullOrEmpty(algorithmName) && pairAlgorithmTimeout.ContainsKey(algorithmName))
                {
                    return(pairAlgorithmTimeout[algorithmName]);
                }

                return(config.GeneralTimeout);
            }
            return(defaultMaxTimeout);
        }
Example #3
0
        public static bool ParseIsEnabled(bool defaultValue, MinerApiMaxTimeoutSetting config)
        {
            if (config?.UseUserSettings ?? false)
            {
                return(config.Enabled);
            }

            return(defaultValue);
        }
Example #4
0
 // TODO document
 public static MinerApiMaxTimeoutSetting InitMinerApiMaxTimeoutSetting(string pluginRoot, MinerApiMaxTimeoutSetting minerApiMaxTimeoutSetting)
 {
     return(InitInternalSetting(pluginRoot, minerApiMaxTimeoutSetting, "MinerApiMaxTimeoutSetting.json"));
 }