Exemplo n.º 1
0
        public static void InitializePackages()
        {
            var defaults = new List <MinerPathPackage>();

            for (var i = DeviceGroupType.NONE + 1; i < DeviceGroupType.LAST; i++)
            {
                var minerTypePaths = new List <MinerTypePath>();
                var package        = GroupAlgorithms.CreateDefaultsForGroup(i);
                foreach (var type in configurableMiners)
                {
                    if (package.ContainsKey(type))
                    {
                        var minerPaths = new List <MinerPath>();
                        foreach (var algo in package[type])
                        {
                            minerPaths.Add(new MinerPath(algo.NiceHashID, GetPathFor(type, algo.NiceHashID, i, true)));
                        }
                        minerTypePaths.Add(new MinerTypePath(type, minerPaths));
                    }
                }
                if (minerTypePaths.Count > 0)
                {
                    defaults.Add(new MinerPathPackage(i, minerTypePaths));
                }
            }

            foreach (var pack in defaults)
            {
                var packageName = String.Format("MinerPathPackage_{0}", pack.Name);
                var packageFile = new MinerPathPackageFile(packageName);
                var readPack    = packageFile.ReadFile();
                if (readPack == null)     // read has failed
                {
                    Helpers.ConsolePrint("MinerPaths", "Creating internal paths config " + packageName);
                    minerPathPackages.Add(pack);
                    packageFile.Commit(pack);
                }
                else
                {
                    Helpers.ConsolePrint("MinerPaths", "Loading internal paths config " + packageName);
                    minerPathPackages.Add(readPack);
                }
            }
        }
Exemplo n.º 2
0
        public static void InitializePackages()
        {
            var defaults = new List <MinerPathPackage>();

            for (var i = DeviceGroupType.NONE + 1; i < DeviceGroupType.LAST; i++)
            {
                var package        = GroupAlgorithms.CreateDefaultsForGroup(i);
                var minerTypePaths = (from type in ConfigurableMiners
                                      where package.ContainsKey(type)
                                      let minerPaths = package[type].Select(algo =>
                                                                            new MinerPath(algo.NiceHashID, GetPathFor(type, algo.NiceHashID, i, true))).ToList()
                                                       select new MinerTypePath(type, minerPaths)).ToList();
                if (minerTypePaths.Count > 0)
                {
                    defaults.Add(new MinerPathPackage(i, minerTypePaths));
                }
            }

            foreach (var pack in defaults)
            {
                var packageName = $"MinerPathPackage_{pack.Name}";
                var packageFile = new MinerPathPackageFile(packageName);
                var readPack    = packageFile.ReadFile();
                if (readPack == null)
                {
                    // read has failed
                    Helpers.ConsolePrint("MinerPaths", "Creating internal paths config " + packageName);
                    MinerPathPackages.Add(pack);
                    packageFile.Commit(pack);
                }
                else
                {
                    Helpers.ConsolePrint("MinerPaths", "Loading internal paths config " + packageName);
                    var isChange = false;
                    foreach (var miner in pack.MinerTypes)
                    {
                        var readMiner = readPack.MinerTypes.Find(x => x.Type == miner.Type);
                        if (readMiner != null)
                        {
                            // file contains miner type
                            foreach (var algo in miner.Algorithms)
                            {
                                if (!readMiner.Algorithms.Exists(x => x.Algorithm == algo.Algorithm))
                                {
                                    // file does not contain algo on this miner
                                    Helpers.ConsolePrint("PATHS",
                                                         $"Algorithm {algo.Name} not found in miner {miner.Name} on device {pack.Name}. Adding default");
                                    readMiner.Algorithms.Add(algo);
                                    isChange = true;
                                }
                            }
                        }
                        else
                        {
                            // file does not contain miner type
                            Helpers.ConsolePrint("PATHS", $"Miner {miner.Name} not found on device {pack.Name}");
                            readPack.MinerTypes.Add(miner);
                            isChange = true;
                        }
                    }
                    MinerPathPackages.Add(readPack);
                    if (isChange)
                    {
                        packageFile.Commit(readPack);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static void InitializePackages()
        {
            var defaults = new List <MinerPathPackage>();

            for (var i = DeviceGroupType.NONE + 1; i < DeviceGroupType.LAST; i++)
            {
                var minerTypePaths = new List <MinerTypePath>();
                var package        = GroupAlgorithms.CreateDefaultsForGroup(i);
                foreach (var type in configurableMiners)
                {
                    if (package.ContainsKey(type))
                    {
                        var minerPaths = new List <MinerPath>();
                        foreach (var algo in package[type])
                        {
                            minerPaths.Add(new MinerPath(algo.NiceHashID, GetPathFor(type, algo.NiceHashID, i, true)));
                        }
                        minerTypePaths.Add(new MinerTypePath(type, minerPaths));
                    }
                }
                if (minerTypePaths.Count > 0)
                {
                    defaults.Add(new MinerPathPackage(i, minerTypePaths));
                }
            }

            foreach (var pack in defaults)
            {
                var packageName = String.Format("MinerPathPackage_{0}", pack.Name);
                var packageFile = new MinerPathPackageFile(packageName);
                var readPack    = packageFile.ReadFile();
                if (readPack == null)     // read has failed
                {
                    Helpers.ConsolePrint("MinerPaths", "Creating internal paths config " + packageName);
                    minerPathPackages.Add(pack);
                    packageFile.Commit(pack);
                }
                else
                {
                    Helpers.ConsolePrint("MinerPaths", "Loading internal paths config " + packageName);
                    var isChange = false;
                    foreach (var miner in pack.MinerTypes)
                    {
                        var readMiner = readPack.MinerTypes.Find(x => x.Type == miner.Type);
                        if (readMiner != null)    // file contains miner type
                        {
                            foreach (var algo in miner.Algorithms)
                            {
                                if (!readMiner.Algorithms.Exists(x => x.Algorithm == algo.Algorithm))    // file does not contain algo on this miner
                                {
                                    Helpers.ConsolePrint("PATHS", String.Format("Algorithm {0} not found in miner {1} on device {2}. Adding default", algo.Name, miner.Name, pack.Name));
                                    readMiner.Algorithms.Add(algo);
                                    isChange = true;
                                }
                            }
                        }
                        else      // file does not contain miner type
                        {
                            Helpers.ConsolePrint("PATHS", String.Format("Miner {0} not found on device {1}", miner.Name, pack.Name));
                            readPack.MinerTypes.Add(miner);
                            isChange = true;
                        }
                    }
                    minerPathPackages.Add(readPack);
                    if (isChange)
                    {
                        packageFile.Commit(readPack);
                    }
                }
            }
        }