コード例 #1
0
        public static void InitMinerReservedPortsFile()
        {
            var file = new MinerReservedPortsFile();

            _minerReservedPorts = new Dictionary <MinerBaseType, Dictionary <string, Dictionary <AlgorithmType, List <int> > > >();
            if (file.IsFileExists())
            {
                var read = file.ReadFile();
                if (read != null)
                {
                    _minerReservedPorts = read;
                }
            }
            try
            {
                for (var type = (MinerBaseType.NONE + 1); type < MinerBaseType.END; ++type)
                {
                    if (_minerReservedPorts.ContainsKey(type) == false)
                    {
                        _minerReservedPorts[type] = new Dictionary <string, Dictionary <AlgorithmType, List <int> > >();
                    }
                }
                for (var devGroupType = (DeviceGroupType.NONE + 1); devGroupType < DeviceGroupType.LAST; ++devGroupType)
                {
                    var minerAlgosForGroup = GroupAlgorithms.CreateDefaultsForGroup(devGroupType);
                    if (minerAlgosForGroup != null)
                    {
                        foreach (var mbaseKvp in minerAlgosForGroup)
                        {
                            var minerBaseType = mbaseKvp.Key;
                            if (_minerReservedPorts.ContainsKey(minerBaseType))
                            {
                                var algos = mbaseKvp.Value;
                                foreach (var algo in algos)
                                {
                                    var algoType    = algo.NiceHashID;
                                    var path        = MinerPaths.GetPathFor(minerBaseType, algoType, devGroupType);
                                    var isPathValid = path != MinerPaths.Data.None;
                                    if (isPathValid && _minerReservedPorts[minerBaseType].ContainsKey(path) == false)
                                    {
                                        _minerReservedPorts[minerBaseType][path] = new Dictionary <AlgorithmType, List <int> >();
                                    }
                                    if (isPathValid && _minerReservedPorts[minerBaseType][path] != null &&
                                        _minerReservedPorts[minerBaseType][path].ContainsKey(algoType) == false)
                                    {
                                        _minerReservedPorts[minerBaseType][path][algoType] = new List <int>();
                                    }
                                }
                            }
                        }
                    }
                }
                file.Commit(_minerReservedPorts);
                // set all reserved
                foreach (var paths in _minerReservedPorts.Values)
                {
                    foreach (var algos in paths.Values)
                    {
                        foreach (var ports in algos.Values)
                        {
                            foreach (var port in ports)
                            {
                                AllReservedPorts.Add(port);
                            }
                        }
                    }
                }
            }
            catch { }
        }
コード例 #2
0
        public static void InitMinerReservedPortsFile()
        {
            var AMDCodenames = new List <string>()
            {
                "Hawaii", "Pitcairn", "Tahiti"
            };
            var AMDOptimizations = new List <bool>()
            {
                true, false
            };
            var CPUExtensions = new List <CPUExtensionType>()
            {
                CPUExtensionType.AVX2_AES,
                CPUExtensionType.AVX2,
                CPUExtensionType.AVX_AES,
                CPUExtensionType.AVX,
                CPUExtensionType.AES,
                CPUExtensionType.SSE2
            };
            MinerReservedPortsFile file = new MinerReservedPortsFile();

            MinerReservedPorts = new Dictionary <MinerBaseType, Dictionary <string, Dictionary <AlgorithmType, List <int> > > >();
            if (file.IsFileExists())
            {
                var read = file.ReadFile();
                if (read != null)
                {
                    MinerReservedPorts = read;
                }
            }
            try {
                for (MinerBaseType type = (MinerBaseType.NONE + 1); type < MinerBaseType.END; ++type)
                {
                    if (MinerReservedPorts.ContainsKey(type) == false)
                    {
                        MinerReservedPorts[type] = new Dictionary <string, Dictionary <AlgorithmType, List <int> > >();
                    }
                }
                for (DeviceGroupType devGroupType = (DeviceGroupType.NONE + 1); devGroupType < DeviceGroupType.LAST; ++devGroupType)
                {
                    var minerAlgosForGroup = GroupAlgorithms.CreateDefaultsForGroup(devGroupType);
                    if (minerAlgosForGroup != null)
                    {
                        foreach (var mbaseKvp in minerAlgosForGroup)
                        {
                            MinerBaseType minerBaseType = mbaseKvp.Key;
                            if (MinerReservedPorts.ContainsKey(minerBaseType))
                            {
                                var algos = mbaseKvp.Value;
                                // CPU case
                                if (MinerBaseType.cpuminer == minerBaseType)
                                {
                                    foreach (var algo in algos)
                                    {
                                        foreach (var cpuExt in CPUExtensions)
                                        {
                                            var algoType = algo.NiceHashID;
                                            var path     = MinerPaths.GetPathFor(minerBaseType, algoType, devGroupType, "", false, cpuExt);
                                            if (path != MinerPaths.NONE && MinerReservedPorts[minerBaseType].ContainsKey(path) == false)
                                            {
                                                MinerReservedPorts[minerBaseType][path] = new Dictionary <AlgorithmType, List <int> >();
                                            }
                                            if (MinerReservedPorts[minerBaseType][path] != null && MinerReservedPorts[minerBaseType][path].ContainsKey(algoType) == false)
                                            {
                                                MinerReservedPorts[minerBaseType][path][algoType] = new List <int>();
                                            }
                                        }
                                    }
                                }
                                else if (MinerBaseType.sgminer == minerBaseType)
                                {
                                    foreach (var algo in algos)
                                    {
                                        foreach (var isOptimized in AMDOptimizations)
                                        {
                                            foreach (var codename in AMDCodenames)
                                            {
                                                var algoType = algo.NiceHashID;
                                                var path     = MinerPaths.GetPathFor(minerBaseType, algoType, devGroupType, codename, isOptimized, CPUExtensionType.Automatic);
                                                if (path != MinerPaths.NONE && MinerReservedPorts[minerBaseType].ContainsKey(path) == false)
                                                {
                                                    MinerReservedPorts[minerBaseType][path] = new Dictionary <AlgorithmType, List <int> >();
                                                }
                                                if (MinerReservedPorts[minerBaseType][path] != null && MinerReservedPorts[minerBaseType][path].ContainsKey(algoType) == false)
                                                {
                                                    MinerReservedPorts[minerBaseType][path][algoType] = new List <int>();
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (var algo in algos)
                                    {
                                        var algoType = algo.NiceHashID;
                                        var path     = MinerPaths.GetPathFor(minerBaseType, algoType, devGroupType, "", false, CPUExtensionType.Automatic);
                                        if (path != MinerPaths.NONE && MinerReservedPorts[minerBaseType].ContainsKey(path) == false)
                                        {
                                            MinerReservedPorts[minerBaseType][path] = new Dictionary <AlgorithmType, List <int> >();
                                        }
                                        if (MinerReservedPorts[minerBaseType][path] != null && MinerReservedPorts[minerBaseType][path].ContainsKey(algoType) == false)
                                        {
                                            MinerReservedPorts[minerBaseType][path][algoType] = new List <int>();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                file.Commit(MinerReservedPorts);
                // set all reserved
                foreach (var paths in MinerReservedPorts.Values)
                {
                    foreach (var algos in paths.Values)
                    {
                        foreach (var ports in algos.Values)
                        {
                            foreach (int port in ports)
                            {
                                AllReservedPorts.Add(port);
                            }
                        }
                    }
                }
            } catch {
            }
        }