Exemplo n.º 1
0
        private void StopMining(object obj)
        {
            IsMining = false;
            MiningTimer.Stop();
            HashRate = null;

            try
            {
                AppVM.Geth.Miner.Stop.SendRequestAsync().GetAwaiter().GetResult();

                //var unlockAccountResult =
                //    Task.Run(() => AppVM.Geth.Personal.LockAccount.SendRequestAsync(PublicKey)).Result;
            }
            catch (Exception)
            {
            }
            //    Service.StopMining(PublicKey, Password);
            StartMiningCommand.Label = "Start Mining";
            MiningStatus             = "MINING STATUS: NOT MINING";
        }
Exemplo n.º 2
0
        private void StartMining(object obj)
        {
            if (NodeCount == 0)
            {
                MessageBox.Show("You are connected to 0 nodes. Wait until you are connected to at least one node before mining.", "Wallet", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (AppVM.Instance.MiningSliderValue > 8)
            {
                if (MessageBox.Show($"You have selected {AppVM.Instance.MiningSliderValue} threads to mine with. This is likely to consume most of your system resources. Continue?", "Wallet", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }
            }

            int value = AppVM.Instance.MiningSliderValue;

            //EnterPassphraseWindow window = new EnterPassphraseWindow();
            //window.Owner = Application.Current.MainWindow;
            //window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            //EnterPassphraseVM vm = new EnterPassphraseVM(() => window.Close(), PublicKey);
            //window.DataContext = vm;
            //window.ShowDialog();

            //if (!vm.Confirmed)
            //{
            //    return;
            //}

            //var unlockAccountResult =
            //    Task.Run(() => AppVM.Geth.Personal.UnlockAccount.SendRequestAsync(PublicKey, vm.Passphrase, 1000)).Result;

            try
            {
                AppVM.Geth.Miner.Start.SendRequestAsync(value).GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to start mining. Try closing and reopening this program to see if that fixes it.", "Wallet", MessageBoxButton.OK);
                return;
            }



            Thread.Sleep(2000);

            if (AppVM.ProcessID.HasValue)
            {
                try
                {
                    Process.GetProcessById(AppVM.ProcessID.Value);
                }
                catch (ArgumentException e)
                {
                    MessageBox.Show("The mining process has crashed. Please reopen the wallet.", "Wallet", MessageBoxButton.OK);
                    Application.Current.Shutdown();
                }
            }

            IsMining = true;

            MiningTimer.Start();


            //   Service.StartMining(PublicKey, Password, MiningSliderValue);
            StartMiningCommand.Label = "Stop Mining";
            MiningStatus             = "MINING STATUS: MINING";
        }