Esempio n. 1
0
        public static async void DisplayDwarfUserStatsAsync(DwarfUserInformation dwarfUserInformation)
        {
            WriteInColor("DwarfPool Ethereum\n", ConsoleColor.Red);
            WriteInColor("Performance Monitoring\n", ConsoleColor.Cyan);
            Console.WriteLine();
            Console.Write("Total sent hashrate: ");
            WriteInColor(dwarfUserInformation.DwarfUser.Total_hashrate + " Mh/s.\n", ConsoleColor.Green);
            Console.Write("Total calculated hashrate: ");
            WriteInColor(dwarfUserInformation.DwarfUser.Total_hashrate_calculated + " Mh/s.\n\n", ConsoleColor.Green);
            WriteInColor("Current Running Rig\n", ConsoleColor.Cyan);
            Console.WriteLine(String.Format("Total: {0}", dwarfUserInformation.NumberOfRig));
            Console.WriteLine();
            int number = 1;

            foreach (var worker in dwarfUserInformation.Workers)
            {
                string workerName = number + ". " + worker.Worker;
                Console.WriteLine(workerName);
                Helper.Underline(workerName, "-");
                Console.Write("Current Hashrate: ");
                WriteInColor(worker.Hashrate + " Mh/s.\n", ConsoleColor.Green);
                Console.Write("Last Work Submit: ");
                DateTime convertedDate = DateTime.SpecifyKind(DateTime.Parse(worker.Last_submit), DateTimeKind.Utc);
                WriteInColor(convertedDate.ToString("dddd, dd MMMM yyyy HH:mm:ss", CultureInfo.CreateSpecificCulture("en-US")) + "\n", ConsoleColor.Yellow);
                number += 1;
            }
            Console.Write("Payout Limit: ");
            WriteInColor(dwarfUserInformation.PayOutLimit + " ETH.\n\n", ConsoleColor.Red);
            WriteInColor("Mining in Progress\n\n", ConsoleColor.Cyan);
            Console.Write("Amount mined: ");
            WriteInColor(dwarfUserInformation.DwarfUser.Wallet_balance, ConsoleColor.Magenta);
            Console.Write(" / " + dwarfUserInformation.PayOutLimit + "\n");
            Task <int> task   = ShowMiningProgression(double.Parse(dwarfUserInformation.DwarfUser.Wallet_balance), dwarfUserInformation.PayOutLimit);
            int        result = await task;
        }
        public UserInformation GetDwarfUserInformation(Helper.DwarfPoolConfig dwarfConfig)
        {
            client.BaseAddress = new Uri(dwarfConfig.BaseUri);
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = client.GetAsync("api?wallet=" + dwarfConfig.WalletAddress + "&[email protected]").Result;  // Blocking call!

            if (response.IsSuccessStatusCode)
            {
                // Parse the response body. Blocking!
                string             jsonString    = response.Content.ReadAsStringAsync().Result;
                var                jObject       = Newtonsoft.Json.Linq.JObject.Parse(jsonString);
                DwarfUser          dwarfUser     = JsonConvert.DeserializeObject <DwarfUser>(jObject.ToString());
                var                workersString = jObject["workers"].First();
                List <DwarfWorker> workersList   = new List <DwarfWorker>();
                foreach (var worker in workersString)
                {
                    workersList.Add(JsonConvert.DeserializeObject <DwarfWorker>(worker.ToString()));
                }
                DwarfUserInformation dwarfuserInformation = new DwarfUserInformation()
                {
                    DwarfUser   = dwarfUser,
                    Workers     = workersList,
                    NumberOfRig = workersString.Count(),
                    PayOutLimit = dwarfConfig.PayOutLimit
                };
                return(new UserInformation()
                {
                    DwarfUserInformation = dwarfuserInformation
                });
            }
            else
            {
                return(null);
            }
        }