Пример #1
0
        private void SendAuthorize()
        {
            var command = new StratumCommand
            {
                Id         = CommandGlobalId++,
                Method     = "mining.authorize",
                Parameters = new ArrayList {
                    _stratumConnection.UserName, _stratumConnection.Password
                }
            };

            var request = Helpers.JsonSerialize(command) + "\n";

            var bytesSent = Encoding.ASCII.GetBytes(request);

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

                if (command.Id != null)
                {
                    PendingAcks.Add(command.Id, command.Method);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Socket error:" + ex.Message);
                ConnectToServer();
            }
        }
Пример #2
0
        private void SendSubscribe()
        {
            var command = new StratumCommand
            {
                Id         = ID++,
                Method     = "mining.subscribe",
                Parameters = new ArrayList()
            };


            var request = Helpers.JsonSerialize(command) + "\n";

            var bytesSent = Encoding.ASCII.GetBytes(request);

            try
            {
                _tcpClient.GetStream().Write(bytesSent, 0, bytesSent.Length);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Socket error:" + ex.Message);
                ConnectToServer();
            }
        }