Ejemplo n.º 1
0
        public MinerDescriptor GetMiner(DeviceKind deviceKind, CoinAlgorithm algorithm, SerializableDictionary<CoinAlgorithm, string> miners)
        {
            if (deviceKind != DeviceKind.GPU)
                return GetDefaultMiner();

            if (miners.ContainsKey(algorithm))
                return Miners.Single(m => m.Name.Equals(miners[algorithm], StringComparison.OrdinalIgnoreCase));
            else
                return DefaultMiners[algorithm];
        }
Ejemplo n.º 2
0
        public bool SupportsAlgorithm(CoinAlgorithm algorithm)
        {
            bool result = false;

            if (algorithm == CoinAlgorithm.Scrypt)
            {
                result = (Kind == DeviceKind.GPU) || (Kind == DeviceKind.CPU) || IsScryptAsic();
            }
            else
            {
                result = !IsScryptAsic();
            }

            return result;
        }
Ejemplo n.º 3
0
        public bool SupportsAlgorithm(CoinAlgorithm algorithm)
        {
            bool result = false;

            if (algorithm == CoinAlgorithm.Scrypt)
            {
                result = (Kind == DeviceKind.GPU) || (Kind == DeviceKind.CPU) || IsScryptAsic();
            }
            else
            {
                result = !IsScryptAsic();
            }

            return(result);
        }
Ejemplo n.º 4
0
        public MinerDescriptor GetMiner(DeviceKind deviceKind, CoinAlgorithm algorithm, SerializableDictionary<string, string> miners)
        {
            if (deviceKind != DeviceKind.GPU)
                return GetDefaultMiner();

            string algorithmName = algorithm.Name;

			MinerDescriptor result = null;

            if (miners.ContainsKey(algorithmName))
				// SingleOrDefault - the user may have a config file with a backend
				// miner registered that no longer exists in their Miners\ folder
				result = Miners.SingleOrDefault(m => m.Name.Equals(miners[algorithmName], StringComparison.OrdinalIgnoreCase));
            if ((result == null) && (algorithm.DefaultMiner != null))
				result = Miners.Single(m => m.Name.Equals(algorithm.DefaultMiner, StringComparison.OrdinalIgnoreCase));

            return result;
        }
Ejemplo n.º 5
0
        private static double GetTotalHashrate(MinerFormViewModel viewModel, CoinAlgorithm algorithm, bool includeNetworkDevices)
        {
            double result = 0.00;

            //only include Visible devices
            foreach (DeviceViewModel device in viewModel.Devices.Where(d => d.Visible))
            {
                if ((device.Coin != null) &&

                    //lump Scrypt-alts in with Scrypt for now
                    (device.Coin.Algorithm == algorithm) &&

                    //optionally filter out Network Devices
                    (includeNetworkDevices || (device.Kind != DeviceKind.NET)))
                    result += device.CurrentHashrate;
            }

            return result;
        }
Ejemplo n.º 6
0
        private static ToolStripMenuItem FindOrCreateAlgoMenuItem(ToolStripItemCollection parent, CoinAlgorithm algorithm)
        {
            ToolStripMenuItem algoItem = null;

            foreach (ToolStripMenuItem item in parent)
            {
                if (item.Text.Equals(algorithm.ToString()))
                {
                    algoItem = item;
                    break;
                }
            }

            if (algoItem == null)
            {
                algoItem = new ToolStripMenuItem()
                {
                    Text = algorithm.ToString()
                };
                parent.Add(algoItem);
            }

            return algoItem;
        }
Ejemplo n.º 7
0
 private double GetVisibleInstanceHashrate(CoinAlgorithm algorithm, bool includeNetworkDevices)
 {
     return GetTotalHashrate(GetViewModelToView(), algorithm, includeNetworkDevices);
 }
Ejemplo n.º 8
0
 private double GetLocalInstanceHashrate(CoinAlgorithm algorithm, bool includeNetworkDevices)
 {
     return GetTotalHashrate(localViewModel, algorithm, includeNetworkDevices);
 }
Ejemplo n.º 9
0
        private static double AdjustWorkUtilityForPoolMultipliers(double workUtility, CoinAlgorithm algorithm)
        {
            if ((algorithm == CoinAlgorithm.Scrypt) ||
                (algorithm == CoinAlgorithm.ScryptN) ||
                (algorithm == CoinAlgorithm.ScryptJane))
            {
                const int DumbScryptMultiplier = 65536;
                return workUtility / DumbScryptMultiplier;
            }

            if ((algorithm == CoinAlgorithm.Keccak) ||
                (algorithm == CoinAlgorithm.Groestl))
            {
                const int DumbSHA3Multiplier = 256;
                return workUtility / DumbSHA3Multiplier;
            }

            return workUtility;
        }
Ejemplo n.º 10
0
        private List<Device> ListDevices(bool prettyNames, CoinAlgorithm algorithm)
        {
            string arguments = MinerParameter.DeviceList;
            bool redirectOutput = true;

            string serialArg = GetListSerialArguments();

            arguments = String.Format("{0} {1}", arguments, serialArg);

            //include Scrypt ASICs
            if (algorithm == CoinAlgorithm.Scrypt)
                arguments = String.Format("{0} {1}", arguments, MinerParameter.Scrypt);

            //include the args specified by the user so we pickup manual devices (e.g. Avalon)
            arguments = String.Format("{0} {1}", arguments, minerConfiguration.ScanArguments);

            //ADL mismatch with OCL can cause an error / exception, disable ADL when enumerating devices
            //user can then disable for mining in-app using settings
            //this also prevents nice names for GPUs
            //arguments = arguments + " --no-adl";

            //this must be done async, with 70+ devices doing this synchronous
            //locks up the process
            Process minerProcess = StartMinerProcess(arguments, redirectOutput, false, "", false);
            List<string> output = new List<string>();
            minerProcess.OutputDataReceived += (sender, e) =>
            {
                if (e.Data != null)
                {
                    string s = e.Data;
                    output.Add(s);
                }
            };

            minerProcess.Start();

            minerProcess.BeginOutputReadLine();
            //calling BeginErrorReadLine here is *required* on at least one user's machine
            minerProcess.BeginErrorReadLine();

            //wait 5 minutes - scans may take a long time
            minerProcess.WaitForExit(5 * 60 * 1000);

            List<Device> result = new List<Device>();

            DeviceListParser.ParseTextForDevices(output, result);

            if (prettyNames)
                MakeNamesPretty(result);

            return result;
        }
Ejemplo n.º 11
0
 private static bool AlgorithmIsSupported(CoinAlgorithm algorithm)
 {
     return MinerFactory.Instance.DefaultMiners.ContainsKey(algorithm);
 }
Ejemplo n.º 12
0
 public CoinAlgorithm RegisterAlgorithm(string name, string fullName, CoinAlgorithm.AlgorithmFamily family)
 {
     CoinAlgorithm algorithm = new CoinAlgorithm()
     {
         Name = name,
         FullName = fullName,
         Family = family
     };
     Algorithms.Add(algorithm);
     return algorithm;
 }