Пример #1
0
        public void SendAUTHORIZE()
        {
            Byte[]         bytesSent;
            ZtratumCommand Command = new ZtratumCommand();

            Command.id         = ID++;
            Command.method     = "mining.authorize";
            Command.parameters = new ArrayList();
            Command.parameters.Add(Username);
            Command.parameters.Add(Password);

            string request = Utilities.JsonSerialize(Command) + "\n";

            bytesSent = Encoding.ASCII.GetBytes(request);

            try
            {
                tcpClient.GetStream().Write(bytesSent, 0, bytesSent.Length);
                HT ht = new HT(Command.id, Command.method);
                PendingACKs.Add(ht);
            }
            catch (Exception ex)
            {
                if (!GV.StopMining)
                {
                    main.WriteLog("Socket error:" + ex.Message);
                    ConnectToServer(Server, Port, Username, Password);
                }

                return; //
            }

            main.WriteLog("Sent mining.authorize");
        }
Пример #2
0
        public void SendSUBMIT(string JobID, string nTime, uint Nonce, double Difficulty)
        {
            ZtratumCommand Command = new ZtratumCommand();

            Command.id         = ID++;
            Command.method     = "mining.submit";
            Command.parameters = new ArrayList();
            Command.parameters.Add(Username);
            Command.parameters.Add(JobID.ToLower());
            Command.parameters.Add(LittleEndian(ExtraNonce2).ToLower());
            Command.parameters.Add(nTime.ToLower());
            Command.parameters.Add(LittleEndian(Nonce).ToLower());

            string SubmitString = Utilities.JsonSerialize(Command) + "\n";

            Byte[] bytesSent = Encoding.ASCII.GetBytes(SubmitString);

            try
            {
                tcpClient.GetStream().Write(bytesSent, 0, bytesSent.Length);

                main.SharesSubmitted++;
                main.totalShareSubmited++;

                HT ht = new HT(Command.id, Command.method);
                PendingACKs.Add(ht);
            }
            catch (Exception ex)
            {
                if (!GV.StopMining)
                {
                    main.WriteLog("Socket error:" + ex.Message);
                    ConnectToServer(Server, Port, Username, Password);
                }

                return; //
            }

            main.WriteLog("Submit (Difficulty " + Difficulty + ")");
        }