Exemplo n.º 1
0
        // Get Pool Information from Database
        public PoolConnectionInformation GetPoolInformationForAddress()
        {
            // Create a disposable network client
            using (WebClient networkClient = new WebClient())
            {
                // Add post parameters
                NameValueCollection postParameters = new NameValueCollection();
                postParameters.Add("password", configuration.GetPostPassword());
                postParameters.Add("address", GetMinerConnectionAddress());

                // Parse to JSON - this acts as a validator
                JObject parsed = JObject.Parse(Encoding.UTF8.GetString(networkClient.UploadValues(configuration.GetPoolInformatonEndpoint(), "POST", postParameters)));

                // Return a new instance of the return type
                return(new PoolConnectionInformation
                {
                    pool_id = UInt32.Parse(parsed["id"].ToString()),
                    user_id = UInt32.Parse(parsed["user_id"].ToString()),
                    name = parsed["name"].ToString(),
                    hostname = parsed["hostname"].ToString(),
                    port = int.Parse(parsed["port"].ToString())
                });
            }
        }