Exemple #1
0
 public static void Init()
 {
     ExtraLaunchParameters.InitializePackages();
     MinerPaths.InitializePackages();
     InitMinerReservedPortsFile();
     InitMinerSystemVariablesFile();
 }
        // create miner creates new miners based on device type and algorithm/miner path
        public static Miner CreateMiner(ComputeDevice device, Algorithm algorithm)
        {
            var minerPath = MinerPaths.GetOptimizedMinerPath(device, algorithm);

            if (minerPath != MinerPaths.NONE)
            {
                return(CreateMiner(device.DeviceType, minerPath));
            }
            return(null);
        }
        // this will not check Ethminer path
        private static bool IsSameBinPath(ComputeDevice a, ComputeDevice b)
        {
            // same group uses same Miner class and therefore same binary path for same algorithm
            bool sameGroup = a.DeviceGroupType == b.DeviceGroupType;

            if (!sameGroup)
            {
                var a_algoType = a.MostProfitableAlgorithm.NiceHashID;
                var b_algoType = b.MostProfitableAlgorithm.NiceHashID;
                // a and b algorithm settings should be the same if we call this function
                return(MinerPaths.GetOptimizedMinerPath(a_algoType, a.DeviceType, a.DeviceGroupType, a.Codename, a.IsOptimizedVersion)
                       == MinerPaths.GetOptimizedMinerPath(b_algoType, b.DeviceType, b.DeviceGroupType, b.Codename, b.IsOptimizedVersion));
            }

            return(true);
        }
Exemple #4
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 { }
        }
Exemple #5
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 {
            }
        }