예제 #1
0
        public MainForm(string username, string publicKey, string privateKey)
        {
            _username                  = username;
            _blockUpdateTimer          = new System.Timers.Timer(10000);
            _miningTimer               = new System.Timers.Timer(1000);
            _blockUpdateTimer.Elapsed += _blockUpdateTimer_Elapsed;
            _miningTimer.Elapsed      += _miningTimer_Elapsed;
            _blockUpdateTimer.Start();
            _privateKey = privateKey;
            _publicKey  = publicKey;
            _chartForm  = new ChartForm();

            _httpClient             = new HttpClientService(_publicKey);
            _miningTokenSource      = new CancellationTokenSource();
            _miningForm             = new MiningForm(_publicKey);
            _miningForm.FormClosed += _miningForm_FormClosed;

            _miningForm.SpeedChanged += _miningForm_SpeedChanged;
            _miningForm.BlockCreated += _miningForm_BlockCreated;
            InitializeComponent();

            var block = _httpClient.GetLastBlock();

            PublicKeyLabel.Text  = _publicKey;
            PrivateKeyLabel.Text = _privateKey.Substring(0, 2) + "********";
            UsernameLabel.Text   = _username;
            LastVerifiedBlock.HashLabelProp.Text  = block?.Hash;
            LastVerifiedBlock.MinerLabelProp.Text = block?.Miner;
            LastVerifiedBlock.DateLabelProp.Text  = block?.Date.ToString();
            LastVerifiedBlock.Show();
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (_isMining)
            {
                _miningTokenSource.Cancel();

                _miningTokenSource    = new CancellationTokenSource();
                _isMining             = false;
                _miningForm._isMining = false;
                button2.Text          = "Mining";
                _miningForm.Close();
                SpeedLabel.Text = "Speed : 0";
                _miningTimer.Stop();
            }
            else
            {
                button2.Text = "Stop";
                _isMining    = true;

                _miningForm = new MiningForm(_publicKey);
                _miningForm.SpeedChanged += _miningForm_SpeedChanged;
                _miningForm.Show();
                _miningForm.Start();
                _miningTimer.Start();
            }
        }