Пример #1
0
        public List<Device> GetDevices(string executablePath)
        {
            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath = executablePath,
                DisableGpu = xgminerConfiguration.DisableGpu,
                DisableUsbProbe = xgminerConfiguration.DisableUsbProbe,
                ScanArguments = xgminerConfiguration.ScanArguments
            };

            Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration);

            List<Device> detectedDevices = miner.ListDevices(true);

            if (xgminerConfiguration.StratumProxy)
            {
                detectedDevices.Add(new Device()
                {
                    Kind = DeviceKind.PXY,
                    Driver = "proxy",
                    Name = "Stratum Proxy"
                });
            }

            SortDevices(detectedDevices);

            return detectedDevices;
        }
Пример #2
0
        public List <Device> GetDevices(string executablePath)
        {
            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath  = executablePath,
                DisableGpu      = xgminerConfiguration.DisableGpu,
                DisableUsbProbe = xgminerConfiguration.DisableUsbProbe,
                ScanArguments   = xgminerConfiguration.ScanArguments
            };

            Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration);

            Version       minerVersion    = new Version(Xgminer.Installer.GetInstalledMinerVersion(executablePath));
            List <Device> detectedDevices = miner.ListDevices(true, minerVersion);

            if (xgminerConfiguration.StratumProxy)
            {
                detectedDevices.Add(new Device()
                {
                    Kind   = DeviceKind.PXY,
                    Driver = "proxy",
                    Name   = "Stratum Proxy"
                });
            }

            SortDevices(detectedDevices);

            return(detectedDevices);
        }
Пример #3
0
        public List<Device> GetDevices(string executablePath)
        {
            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath = executablePath,
                DisableGpu = xgminerConfiguration.DisableGpu,
                DisableUsbProbe = xgminerConfiguration.DisableUsbProbe,
                ScanArguments = xgminerConfiguration.ScanArguments
            };

            Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration);

            string minerPath = MultiMiner.Engine.MinerPath.GetPathToInstalledMiner();
            Version minerVersion = new Version(Xgminer.Installer.GetInstalledMinerVersion(minerPath));
            List<Device> detectedDevices = miner.ListDevices(true, minerVersion);

            if (xgminerConfiguration.StratumProxy)
            {
                detectedDevices.Add(new Device()
                {
                    Kind = DeviceKind.PXY,
                    Driver = "proxy",
                    Name = "Stratum Proxy"
                });
            }

            SortDevices(detectedDevices);

            return detectedDevices;
        }
Пример #4
0
        public List<Device> GetDevices(string executablePath)
        {
            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath = executablePath,
                DisableGpu = xgminerConfiguration.DisableGpu,
                DisableUsbProbe = xgminerConfiguration.DisableUsbProbe,
                ScanArguments = xgminerConfiguration.ScanArguments
            };

            Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration, false);

            Version minerVersion = new Version(MinerInstaller.GetInstalledMinerVersion(executablePath, false));
            List<Device> detectedDevices = miner.ListDevices(true, minerVersion, logging: true);

            SortDevices(detectedDevices);

            return detectedDevices;
        }
Пример #5
0
        public List <Device> GetDevices(string executablePath)
        {
            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath  = executablePath,
                DisableGpu      = xgminerConfiguration.DisableGpu,
                DisableUsbProbe = xgminerConfiguration.DisableUsbProbe,
                ScanArguments   = xgminerConfiguration.ScanArguments
            };

            Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration, false);

            Version       minerVersion    = new Version(MinerInstaller.GetInstalledMinerVersion(executablePath, false));
            List <Device> detectedDevices = miner.ListDevices(true, minerVersion, logging: true);

            SortDevices(detectedDevices);

            return(detectedDevices);
        }
Пример #6
0
        public List <Device> GetDevices(MinerDescriptor minerDescriptor, string executablePath)
        {
            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath  = executablePath,
                DisableGpu      = xgminerConfiguration.DisableGpu,
                DisableUsbProbe = xgminerConfiguration.DisableUsbProbe,
                ScanArguments   = xgminerConfiguration.ScanArguments
            };

            Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration, false);

            Version       minerVersion    = new Version(MinerInstaller.GetInstalledMinerVersion(minerDescriptor, executablePath, false));
            List <Device> detectedDevices = miner.ListDevices(true, minerVersion);

            if (xgminerConfiguration.StratumProxy)
            {
                for (int i = 0; i < xgminerConfiguration.StratumProxies.Count; i++)
                {
                    MultiMiner.Engine.Data.Configuration.Xgminer.ProxyDescriptor proxy = xgminerConfiguration.StratumProxies[i];
                    detectedDevices.Add(new Device()
                    {
                        Kind   = DeviceKind.PXY,
                        Driver = "proxy",
                        Name   = String.Format("Stratum Proxy #{0}", (i + 1)),
                        //we want the path in the ViewModel for Remoting
                        //can't rely on having the Stratum Proxy settings
                        Path          = String.Format("{0}:{1}", proxy.GetworkPort, proxy.StratumPort),
                        RelativeIndex = i
                    });
                }
            }

            SortDevices(detectedDevices);

            return(detectedDevices);
        }
Пример #7
0
        public List<Device> GetDevices(MinerDescriptor minerDescriptor, string executablePath)
        {
            Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
            {
                ExecutablePath = executablePath,
                DisableGpu = xgminerConfiguration.DisableGpu,
                DisableUsbProbe = xgminerConfiguration.DisableUsbProbe,
                ScanArguments = xgminerConfiguration.ScanArguments
            };

            Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration, false);

            Version minerVersion = new Version(MinerInstaller.GetInstalledMinerVersion(executablePath, false));
            List<Device> detectedDevices = miner.ListDevices(true, minerVersion);

            if (xgminerConfiguration.StratumProxy)
            {
                for (int i = 0; i < xgminerConfiguration.StratumProxies.Count; i++)
                {
                    MultiMiner.Engine.Data.Configuration.Xgminer.ProxyDescriptor proxy = xgminerConfiguration.StratumProxies[i];
                    detectedDevices.Add(new Device()
                    {
                        Kind = DeviceKind.PXY,
                        Driver = "proxy",
                        Name = String.Format("Stratum Proxy #{0}", (i + 1)),
                        //we want the path in the ViewModel for Remoting
                        //can't rely on having the Stratum Proxy settings
                        Path = String.Format("{0}:{1}", proxy.GetworkPort, proxy.StratumPort),
                        RelativeIndex = i
                    });
                }
            }

            SortDevices(detectedDevices);

            return detectedDevices;
        }
Пример #8
0
        static void Main(string[] args)
        {
            //examples of using MultiMiner.Xgminer.dll and MultiMiner.Xgminer.Api.dll

            //download and install the latest version of Gateless Gate
            const string executablePath = @"D:\gatelessgate\";
            const string executableName = "gatlessgate.exe";
            const string userAgent      = "MultiMiner/V3-Example";

            //download and install bfgminer from MultiMinerApp.com
            List <AvailableMiner> availableMiners = AvailableMiners.GetAvailableMiners(userAgent);
            AvailableMiner        gatelessgate    = availableMiners.Single(am => am.Name.Equals(MinerNames.GatelessGate, StringComparison.OrdinalIgnoreCase));

            Console.WriteLine("Downloading and installing {0} from {1} to the directory {2}",
                              executableName, new Uri(gatelessgate.Url).Authority, executablePath);

            MinerInstaller.InstallMiner(userAgent, gatelessgate, executablePath);
            try
            {
                //create an instance of Miner with the downloaded executable
                Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
                {
                    ExecutablePath = Path.Combine(executablePath, executableName)
                };
                Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration, false);

                //use it to iterate through devices
                List <Device> deviceList = miner.ListDevices();

                Console.WriteLine("Using {0} to list available mining devices", executableName);

                //output devices
                foreach (Device device in deviceList)
                {
                    Console.WriteLine("Device detected: {0}\t{1}\t{2}", device.Kind, device.Driver, device.Name);
                }

                //start mining if there are devices
                if (deviceList.Count > 0)
                {
                    Console.WriteLine("{0} device(s) detected, mining Bitcoin on Bitminter using all devices", deviceList.Count);

                    //setup a pool
                    MiningPool pool = new MiningPool()
                    {
                        Host     = "mint.bitminter.com",
                        Port     = 3333,
                        Username = "******",
                        Password = "******"
                    };
                    minerConfiguration.Pools.Add(pool);

                    //specify algorithm
                    minerConfiguration.Algorithm = MinerFactory.Instance.GetAlgorithm(AlgorithmNames.SHA256);

                    //disable GPU mining
                    minerConfiguration.DisableGpu = true;

                    //specify device indexes to use
                    for (int i = 0; i < deviceList.Count; i++)
                    {
                        minerConfiguration.DeviceDescriptors.Add(deviceList[i]);
                    }

                    //enable RPC API
                    minerConfiguration.ApiListen = true;
                    minerConfiguration.ApiPort   = 4028;

                    Console.WriteLine("Launching {0}", executableName);

                    //start mining
                    miner = new Xgminer.Miner(minerConfiguration, false);
                    System.Diagnostics.Process minerProcess = miner.Launch();
                    try
                    {
                        //get an API context
                        Xgminer.Api.ApiContext apiContext = new Xgminer.Api.ApiContext(minerConfiguration.ApiPort);
                        try
                        {
                            //mine for one minute, monitoring hashrate via the API
                            for (int i = 0; i < 6; i++)
                            {
                                Thread.Sleep(1000 * 10); //sleep 10s

                                //query the miner process via its RPC API for device information
                                List <Xgminer.Api.Data.DeviceInformation> deviceInformation = apiContext.GetDeviceInformation();

                                //output device information
                                foreach (Xgminer.Api.Data.DeviceInformation item in deviceInformation)
                                {
                                    Console.WriteLine("Hasrate for device {0}: {1} current, {2} average", item.Index,
                                                      item.CurrentHashrate, item.AverageHashrate);
                                }
                            }
                        }
                        finally
                        {
                            Console.WriteLine("Quitting mining via the RPC API");

                            //stop mining, try the API first
                            apiContext.QuitMining();
                        }
                    }
                    finally
                    {
                        Console.WriteLine("Killing any remaining process");

                        //then kill the process
                        try
                        {
                            minerProcess.Kill();
                            minerProcess.WaitForExit();
                            minerProcess.Close();
                        }
                        catch (InvalidOperationException)
                        {
                            //already closed
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No devices capable of mining detected");
                }
            }
            finally
            {
                Console.WriteLine("Cleaning up, deleting directory {0}", executablePath);
                Directory.Delete(executablePath, true);
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Пример #9
0
        static void Main(string[] args)
        {
            //examples of using MultiMiner.Xgminer.dll and MultiMiner.Xgminer.Api.dll

            //download and install the latest version of bfgminer
            const string executablePath = @"D:\bfgminer\";
            const string executableName = "bfgminer.exe";

            Console.WriteLine("Downloading and installing {0} from {1} to the directory {2}",
                executableName, Xgminer.Installer.GetMinerDownloadRoot(), executablePath);

            //download and install bfgminer from the official website
            Xgminer.Installer.InstallMiner(executablePath);
            try
            {
                //create an instance of Miner with the downloaded executable
                Xgminer.Data.Configuration.Miner minerConfiguration = new Xgminer.Data.Configuration.Miner()
                {
                    ExecutablePath = Path.Combine(executablePath, executableName)
                };
                Xgminer.Miner miner = new Xgminer.Miner(minerConfiguration);

                //use it to iterate through devices
                List<Device> deviceList = miner.ListDevices();

                Console.WriteLine("Using {0} to list available mining devices", executableName);

                //output devices
                foreach (Device device in deviceList)
                    Console.WriteLine("Device detected: {0}\t{1}\t{2}", device.Kind, device.Driver, device.Name);

                //start mining if there are devices
                if (deviceList.Count > 0)
                {
                    Console.WriteLine("{0} device(s) detected, mining Bitcoin on Bitminter using all devices", deviceList.Count);

                    //setup a pool
                    MiningPool pool = new MiningPool()
                    {
                        Host = "mint.bitminter.com",
                        Port = 3333,
                        Username = "******",
                        Password = "******"
                    };
                    minerConfiguration.Pools.Add(pool);

                    //specify algorithm
                    minerConfiguration.Algorithm = CoinAlgorithm.SHA256;

                    //disable GPU mining
                    minerConfiguration.DisableGpu = true;

                    //specify device indexes to use
                    for (int i = 0; i < deviceList.Count; i++)
                        minerConfiguration.DeviceDescriptors.Add(deviceList[i]);

                    //enable RPC API
                    minerConfiguration.ApiListen = true;
                    minerConfiguration.ApiPort = 4028;

                    Console.WriteLine("Launching {0}", executableName);

                    //start mining
                    miner = new Xgminer.Miner(minerConfiguration);
                    System.Diagnostics.Process minerProcess = miner.Launch();
                    try
                    {
                        //get an API context
                        Xgminer.Api.ApiContext apiContext = new Xgminer.Api.ApiContext(minerConfiguration.ApiPort);
                        try
                        {
                            //mine for one minute, monitoring hashrate via the API
                            for (int i = 0; i < 6; i++)
                            {
                                Thread.Sleep(1000 * 10); //sleep 10s

                                //query the miner process via its RPC API for device information
                                List<Xgminer.Api.Data.DeviceInformation> deviceInformation = apiContext.GetDeviceInformation(minerConfiguration.LogInterval);

                                //output device information
                                foreach (Xgminer.Api.Data.DeviceInformation item in deviceInformation)
                                    Console.WriteLine("Hasrate for device {0}: {1} current, {2} average", item.Index,
                                            item.CurrentHashrate, item.AverageHashrate);
                            }
                        }
                        finally
                        {
                            Console.WriteLine("Quitting mining via the RPC API");

                            //stop mining, try the API first
                            apiContext.QuitMining();
                        }
                    }
                    finally
                    {
                        Console.WriteLine("Killing any remaining process");

                        //then kill the process
                        try
                        {
                            minerProcess.Kill();
                            minerProcess.WaitForExit();
                            minerProcess.Close();
                        }
                        catch (InvalidOperationException ex)
                        {
                            //already closed
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No devices capable of mining detected");
                }
            }
            finally
            {
                Console.WriteLine("Cleaning up, deleting directory {0}", executablePath);
                Directory.Delete(executablePath, true);
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }