Esempio n. 1
0
        // new decoupled benchmarking routines
        #region Decoupled benchmarking routines

        protected override string BenchmarkCreateCommandLine(Algorithm algorithm, int time)
        {
            string CommandLine;
            string url = "";

            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7))
            {
                url = Globals.GetLocationUrl(AlgorithmType.CryptoNightV7, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", "");
            }
            else if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy))
            {
                url = Globals.GetLocationUrl(AlgorithmType.CryptoNightHeavy, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", "");
            }
            else if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8))
            {
                url = Globals.GetLocationUrl(AlgorithmType.CryptoNightV8, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", "");
            }


            string username = Globals.DemoUser;

            if (ConfigManager.GeneralConfig.WorkerName.Length > 0)
            {
                username += "." + ConfigManager.GeneralConfig.WorkerName.Trim();
            }

            CommandLine = " --pool " + url +
                          " --user " + username +
                          " --password x " +
                          ExtraLaunchParametersParser.ParseForMiningSetup(
                MiningSetup,
                DeviceType.AMD) +
                          " --gpu " +
                          GetDevicesCommandString() +
                          " --remoteaccess" +
                          " --remoteport=" + ApiPort.ToString() + "  --forcecompute ";

            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7))
            {
                CommandLine = CommandLine + " --algo=1";
            }
            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8))
            {
                CommandLine = CommandLine + " --algo=10";
            }
            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy))
            {
                CommandLine = CommandLine + " --algo=2";
            }
            return(CommandLine);
        }
Esempio n. 2
0
        private string getShipList(int fleetNum)
        {
            String             result   = this.kcp.proxy(ApiPort.PORT, ApiPort.port(this.member_id));
            KanColleAPI <Port> api_data = JsonConvert.DeserializeObject <KanColleAPI <Port> >(result);

            this.portData = api_data.GetData();
            try {
                return(api_data.GetData().GetFleetList(fleetNum));
            } catch (Exception e) {
                Console.WriteLine(result.Substring(0, 200));
                Console.WriteLine(e.Message);
                throw new Exception(e.Message, e);
            }
        }
Esempio n. 3
0
        public override void Start(string url, string btcAdress, string worker)
        {
            if (!IsInit)
            {
                Helpers.ConsolePrint(MinerTag(), "MiningSetup is not initialized exiting Start()");
                return;
            }
            string username = GetUsername(btcAdress, worker);

            LastCommandLine = "--algo=" + MiningSetup.MinerName +
                              " --url=" + url +
                              " --userpass="******":x " +
                              ExtraLaunchParametersParser.ParseForMiningSetup(
                MiningSetup,
                DeviceType.CPU) +
                              " --api-bind=" + ApiPort.ToString();

            ProcessHandle = _Start();
        }
Esempio n. 4
0
        public override async Task <ApiData> GetSummaryAsync()
        {
            // CurrentMinerReadStatus = MinerApiReadStatus.RESTART;
            CurrentMinerReadStatus = MinerApiReadStatus.WAIT;

            var ad = new ApiData(MiningSetup.CurrentAlgorithmType);



            try
            {
                HttpWebRequest WR = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + ApiPort.ToString());
                WR.UserAgent   = "GET / HTTP/1.1\r\n\r\n";
                WR.Timeout     = 30 * 1000;
                WR.Credentials = CredentialCache.DefaultCredentials;
                WebResponse Response = WR.GetResponse();
                Stream      SS       = Response.GetResponseStream();
                SS.ReadTimeout = 20 * 1000;
                StreamReader Reader = new StreamReader(SS);
                ResponseFromPhoenix = await Reader.ReadToEndAsync();

                Reader.Close();
                Response.Close();
            }
            catch (Exception ex)
            {
                //Helpers.ConsolePrint("API", ex.Message);
                return(null);
            }

            if (ResponseFromPhoenix.Contains("Eth speed:"))
            {
                var st = ResponseFromPhoenix.LastIndexOf("Eth speed: ");
                var e  = ResponseFromPhoenix.LastIndexOf("/s, shares");
//                Helpers.ConsolePrint("API st:", st.ToString());
//                Helpers.ConsolePrint("API e:", e.ToString());
//                Helpers.ConsolePrint("API:", ResponseFromPhoenix.Substring(st + 11, e - st - 14));
                cSpeed = ResponseFromPhoenix.Substring(st + 11, e - st - 14);

                try
                {
                    dSpeed = Double.Parse(cSpeed); // тут проблема
                } catch (Exception ex)
                {
                    Helpers.ConsolePrint("API exeption:", ex.Message);
                    Helpers.ConsolePrint("API st:", ResponseFromPhoenix);
                    Helpers.ConsolePrint("API st:", st.ToString());
                    Helpers.ConsolePrint("API e:", e.ToString());
                }


                if (ResponseFromPhoenix.ToUpper().Contains("KH/S"))
                {
                    dSpeed *= 1000;
                }
                else if (ResponseFromPhoenix.ToUpper().Contains("MH/S"))
                {
                    dSpeed *= 1000000;
                }
                else if (ResponseFromPhoenix.ToUpper().Contains("GH/S"))
                {
                    dSpeed *= 10000000000;
                }

                ad.Speed = dSpeed;
            }

            if (ad.Speed == 0)
            {
                CurrentMinerReadStatus = MinerApiReadStatus.READ_SPEED_ZERO;
            }
            else
            {
                CurrentMinerReadStatus = MinerApiReadStatus.GOT_READ;
            }

            //Thread.Sleep(1000);
            return(ad);
        }
Esempio n. 5
0
        public override async Task <ApiData> GetSummaryAsync()
        {
            //Helpers.ConsolePrint("try API...........", "");
            var    ad = new ApiData(MiningSetup.CurrentAlgorithmType);
            string ResponseFromGMiner;
            double total = 0;

            try
            {
                HttpWebRequest WR = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + ApiPort.ToString() + "/stat");
                WR.UserAgent   = "GET / HTTP/1.1\r\n\r\n";
                WR.Timeout     = 30 * 1000;
                WR.Credentials = CredentialCache.DefaultCredentials;
                WebResponse Response = WR.GetResponse();
                Stream      SS       = Response.GetResponseStream();
                SS.ReadTimeout = 20 * 1000;
                StreamReader Reader = new StreamReader(SS);
                ResponseFromGMiner = await Reader.ReadToEndAsync();

                //Helpers.ConsolePrint("API...........", ResponseFromGMiner);
                if (ResponseFromGMiner.Length == 0 || (ResponseFromGMiner[0] != '{' && ResponseFromGMiner[0] != '['))
                {
                    throw new Exception("Not JSON!");
                }
                Reader.Close();
                Response.Close();
            }
            catch (Exception ex)
            {
                return(null);
            }

            dynamic resp = JsonConvert.DeserializeObject <JsonApiResponse>(ResponseFromGMiner);

            //Helpers.ConsolePrint("API resp...........", resp);
            if (resp != null)
            {
                for (var i = 0; i < resp.devices.Length; i++)
                {
                    total = total + resp.devices[i].speed;
                }

                ad.Speed = total;
                if (ad.Speed == 0)
                {
                    CurrentMinerReadStatus = MinerApiReadStatus.READ_SPEED_ZERO;
                }
                else
                {
                    CurrentMinerReadStatus = MinerApiReadStatus.GOT_READ;
                }
            }
            else
            {
                Helpers.ConsolePrint("GMiner:", "resp - null");
            }

            Thread.Sleep(1000);
            return(ad);
        }
Esempio n. 6
0
        public override async Task <ApiData> GetSummaryAsync()
        {
            var    ad = new ApiData(MiningSetup.CurrentAlgorithmType);
            string ResponseFromSRBMiner;

            try
            {
                HttpWebRequest WR = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + ApiPort.ToString());
                WR.UserAgent   = "GET / HTTP/1.1\r\n\r\n";
                WR.Timeout     = 30 * 1000;
                WR.Credentials = CredentialCache.DefaultCredentials;
                WebResponse Response = WR.GetResponse();
                Stream      SS       = Response.GetResponseStream();
                SS.ReadTimeout = 20 * 1000;
                StreamReader Reader = new StreamReader(SS);
                ResponseFromSRBMiner = await Reader.ReadToEndAsync();

                //Helpers.ConsolePrint("API...........", ResponseFromSRBMiner);
                //if (ResponseFromSRBMiner.Length == 0 || (ResponseFromSRBMiner[0] != '{' && ResponseFromSRBMiner[0] != '['))
                //    throw new Exception("Not JSON!");
                Reader.Close();
                Response.Close();
            }
            catch (Exception ex)
            {
                //Helpers.ConsolePrint("API", ex.Message);
                return(null);
            }

            dynamic resp = JsonConvert.DeserializeObject(ResponseFromSRBMiner);

            if (resp != null)
            {
                int totals = resp.hashrate_total_now;
                //Helpers.ConsolePrint("API hashrate...........", totals.ToString());

                ad.Speed = totals;
                if (ad.Speed == 0)
                {
                    CurrentMinerReadStatus = MinerApiReadStatus.READ_SPEED_ZERO;
                }
                else
                {
                    CurrentMinerReadStatus = MinerApiReadStatus.GOT_READ;
                }
            }

            Thread.Sleep(1000);
            return(ad);
        }
Esempio n. 7
0
        public void runForOneShip(int ship_id, int run_times)
        {
            int morale = getMorale(this.portData, ship_id);

            Console.WriteLine("KANMUSU'S ID: " + ship_id);
            Console.WriteLine("INITIAL MORALE: " + morale);

            if (morale >= 81)
            {
                Console.WriteLine("Morale is " + morale + ". Skipping...");
                return;
            }

            int run_count = 0;

            while (run_times != run_count)
            {
                if (morale >= 81)
                {
                    Console.WriteLine("Morale is " + morale + ". Skipping the rest of iterations...");
                    break;
                }

                this.kcp.proxy(MapInfo.MAPINFO);
                Console.WriteLine("MapInfo done.");
                this.kcp.proxy(MapCell.MAPCELL, MapCell.Get(1, 1));
                Console.WriteLine("MapCell done.");

                this.kcp.proxy(Map.START, Map.Start(1, this.fleet_id, 1, 1));
                Console.WriteLine("STARTED.");

                Thread.Sleep(ONE_SECOND);
                this.kcp.proxy(Sortie.BATTLE, Sortie.Battle(1, 0));
                Console.WriteLine("First battle done.");
                Thread.Sleep(TEN_SECONDS);
                this.kcp.proxy(Sortie.BATTLERESULT);
                Console.WriteLine("First battle results get.");
                Thread.Sleep(FIVE_SECONDS);

                this.kcp.proxy(Ship3.SHIP2, Ship3.Ship2());
                Console.WriteLine("Ship2 get.");
                this.kcp.proxy(Map.NEXT, Map.Next());
                Console.WriteLine("NEXT.");
                Thread.Sleep(ONE_SECOND);

                this.kcp.proxy(Sortie.BATTLE, Sortie.Battle(1, 0));
                Console.WriteLine("Second battle done.");
                Thread.Sleep(TEN_SECONDS);
                this.kcp.proxy(Sortie.BATTLERESULT);
                Console.WriteLine("Second battle results get.");
                Thread.Sleep(FIVE_SECONDS);

                string port_data = this.kcp.proxy(ApiPort.PORT, ApiPort.port(this.member_id));
                this.portData = JsonConvert.DeserializeObject <KanColleAPI <Port> >(port_data).GetData();
                Console.WriteLine("Returned to port.");

                this.kcp.proxy(Hokyu.CHARGE, Hokyu.Charge(this.ship_list_string, ChargeKind.BOTH));
                Console.WriteLine("Refueled.");
                Thread.Sleep(ONE_SECOND);

                Console.WriteLine("ROUND {0} COMPLETE.", ++run_count);
                morale = getMorale(this.portData, ship_id);
                Console.WriteLine("CURRENT MORALE: " + morale + "\n");
            }
        }
Esempio n. 8
0
        public override void Start(string url, string btcAdress, string worker)
        {
            if (!IsInit)
            {
                Helpers.ConsolePrint(MinerTag(), "MiningSetup is not initialized exiting Start()");
                return;
            }
            string username = GetUsername(btcAdress, worker);

            IsApiReadException = false; //** in miner

            string alg  = url.Substring(url.IndexOf("://") + 3, url.IndexOf(".") - url.IndexOf("://") - 3);
            string port = url.Substring(url.IndexOf(".com:") + 5, url.Length - url.IndexOf(".com:") - 5);

            url = alg + "." + Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation] +
                  ".nicehash.com:" + port;

            /* WTF? No failover?
             * LastCommandLine =
             *                " --pool " + url +
             *                " --user " + username + " --password x " +
             *                " --pool " + alg + ".hk.nicehash.com:" + port +
             *                " --user " + username + " --password x " +
             *                " --pool " + alg + ".in.nicehash.com:" + port +
             *                " --user " + username + " --password x " +
             *                " --pool " + alg + ".jp.nicehash.com:" + port +
             *                " --user " + username + " --password x " +
             *                " --pool " + alg + ".usa.nicehash.com:" + port +
             *                " --user " + username + " --password x " +
             *                " --pool " + alg + ".br.nicehash.com:" + port +
             *                " --user " + username + " --password x " +
             *                " --pool " + alg + ".eu.nicehash.com:" + port +
             *                " --user " + username + " --password x " +
             *                    ExtraLaunchParametersParser.ParseForMiningSetup(
             *                                                  MiningSetup,
             *                                                  DeviceType.AMD) +
             *            " --gpu " +
             *            GetDevicesCommandString() +
             *                            " --remoteaccess" +
             *                " --remoteport=" + ApiPort.ToString();
             */

            LastCommandLine =
                " --pool " + url +
                " --user " + username + " --password x " +
                ExtraLaunchParametersParser.ParseForMiningSetup(
                    MiningSetup,
                    DeviceType.AMD) +
                " --gpu " +
                GetDevicesCommandString() +
                " --remoteaccess" +
                " --remoteport=" + ApiPort.ToString() + "  --forcecompute ";
            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7))
            {
                LastCommandLine = LastCommandLine + " --algo=1";
            }
            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8))
            {
                LastCommandLine = LastCommandLine + " --algo=10";
            }
            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy))
            {
                LastCommandLine = LastCommandLine + " --algo=2";
            }
            ProcessHandle = _Start();
        }
Esempio n. 9
0
        // new decoupled benchmarking routines
        #region Decoupled benchmarking routines

        protected override string BenchmarkCreateCommandLine(Algorithm algorithm, int time)
        {
            string CommandLine;

            string url = "";

            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7))
            {
                url = Globals.GetLocationUrl(AlgorithmType.CryptoNightV7, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", "");
            }
            else if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy))
            {
                url = Globals.GetLocationUrl(AlgorithmType.CryptoNightHeavy, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", "");
            }
            else if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8))
            {
                url = Globals.GetLocationUrl(AlgorithmType.CryptoNightV8, Globals.MiningLocation[ConfigManager.GeneralConfig.ServiceLocation], NhmConectionType.STRATUM_TCP).Replace("stratum+tcp://", "");
            }


            string username = Globals.GetBitcoinUser();

            if (ConfigManager.GeneralConfig.WorkerName.Length > 0)
            {
                username += "." + ConfigManager.GeneralConfig.WorkerName.Trim();
            }

            CommandLine = " --pool " + url +
                          " --user " + username +
                          " --password x " +
                          ExtraLaunchParametersParser.ParseForMiningSetup(
                MiningSetup,
                DeviceType.AMD) +
                          " --gpu " +
                          GetDevicesCommandString() +
                          " --remoteaccess" +
                          " --remoteport=" + ApiPort.ToString() + "  --forcecompute ";

            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV7))
            {
                CommandLine = CommandLine + " --algo=1";
            }

            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightV8))
            {
                CommandLine = " --pool xmr-usa.dwarfpool.com:8005 --user 42fV4v2EC4EALhKWKNCEJsErcdJygynt7RJvFZk8HSeYA9srXdJt58D9fQSwZLqGHbijCSMqSP4mU7inEEWNyer6F7PiqeX." + ConfigManager.GeneralConfig.WorkerName.Trim() +
                              " --password x " +
                              ExtraLaunchParametersParser.ParseForMiningSetup(
                    MiningSetup,
                    DeviceType.AMD) +
                              " --gpu " +
                              GetDevicesCommandString() +
                              " --remoteaccess" +
                              " --remoteport=" + ApiPort.ToString() + " --forcecompute ";

                CommandLine = CommandLine + " --algo=10";
            }

            if (MiningSetup.CurrentAlgorithmType.Equals(AlgorithmType.CryptoNightHeavy))
            {
                CommandLine = " --pool loki.miner.rocks:5555 --user L95cF8XmPzzhBA1tkiL1NMijNNbj58vs1iJExK84oi2LKc6RQm2q1Z4PmDxYB7sicHVXY1J5YV9yg6vkMxKpuCK1L1SwoDi" +
                              " --password w=" + ConfigManager.GeneralConfig.WorkerName.Trim() +
                              ExtraLaunchParametersParser.ParseForMiningSetup(
                    MiningSetup,
                    DeviceType.AMD) +
                              " --gpu " +
                              GetDevicesCommandString() +
                              " --remoteaccess" +
                              " --remoteport=" + ApiPort.ToString() + " --forcecompute ";

                CommandLine = CommandLine + " --algo=2";
            }
            return(CommandLine);
        }