コード例 #1
0
        public void Run(string Server, int Port, string Username, string Password = "")
        {
            throw new NotImplementedException();
            if (Server == "")
            {
                _requestLogger.Error("Missing server URL. URL should be in the format of tcp://megahash.wemineltc.com:3333");
                Environment.Exit(-1);
            }
            else if (Port == 0)
            {
                _requestLogger.Error("Missing server port. URL should be in the format of tcp://megahash.wemineltc.com:3333");
                Environment.Exit(-1);
            }
            else if (Username == "")
            {
                _requestLogger.Error("Missing username");
                Environment.Exit(-1);
            }

            /*
             * else if (Password == "")
             * {
             * Console.WriteLine("Missing password");
             * Environment.Exit(-1);
             * }
             */

            _requestLogger.Error("Connecting to '{0}' on port '{1}' with username '{2}' and password '{3}'", Server, Port, Username, Password);

            Stratum = new StratumClient();

            // Workaround for pools that keep disconnecting if no work is submitted in a certain time period. Send regular mining.authorize commands to keep the connection open
            KeepaliveTimer          = new System.Timers.Timer(45000);
            KeepaliveTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            KeepaliveTimer.Start();

            // Set up event handlers
            Stratum.GotResponse      += stratum_GotResponse;
            Stratum.GotSetDifficulty += stratum_GotSetDifficulty;
            Stratum.GotNotify        += stratum_GotNotify;

            // Connect to the server
            Stratum.ConnectToServer(Server, Port, Username, Password);

            // Start mining!!
            StartCoinMiner();

            // This thread waits forever as the mining happens on other threads. Can press Ctrl+C to exit
            Thread.Sleep(System.Threading.Timeout.Infinite);
        }