-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathForm1.cs
80 lines (65 loc) · 2.99 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
namespace CentralMine.NET
{
public partial class Form1 : Form
{
ClientManager mTheMan;
public Form1()
{
InitializeComponent();
this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
mTheMan = new ClientManager();
protocol.Items.Add(ClientManager.Currency.Bitcoin);
protocol.Items.Add(ClientManager.Currency.Xencoin);
protocol.Items.Add(ClientManager.Currency.Gamerscoin);
protocol.SelectedIndex = 2;
}
void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
timer1.Enabled = false;
mTheMan.Close();
mTheMan = null;
}
private void timer1_Tick(object sender, EventArgs e)
{
// Update block info
if (mTheMan != null && mTheMan.mBlock != null)
{
lblMidstate.Text = "0x" + mTheMan.mBlock.strMidstate;
lblData.Text = "0x" + mTheMan.mBlock.strData;
lblHash1.Text = "0x" + mTheMan.mBlock.strHash1;
lblTarget.Text = "0x" + mTheMan.mBlock.strTarget;
}
groupBox1.Text = mTheMan.mMiningTarget.mName;
lblSubmitted.Text = "Submitted: " + mTheMan.mBlocksSubmitted.ToString();
lblAccepted.Text = "Accepted: " + mTheMan.mBlocksAccepted.ToString();
lblClients.Text = "Clients: " + mTheMan.mClients.Count;
if (mTheMan.mBlock != null)
{
float percent = ((float)mTheMan.mBlock.mHashMan.mHashesDone / (float)mTheMan.mBlock.mHashMan.mHashesTotal) * 100;
progressBar1.Value = (int)percent;
lblProgress.Text = String.Format("{0:N0} / {1:N0} ({2}%)", mTheMan.mBlock.mHashMan.mHashesDone, mTheMan.mBlock.mHashMan.mHashesTotal, percent);
double hashesPerSecond = mTheMan.mHashrate;
uint hashesRemaining = mTheMan.mBlock.mHashMan.mHashesTotal - mTheMan.mBlock.mHashMan.mHashesDone;
double secondsRemaining = (double)hashesRemaining / hashesPerSecond;
int hoursRemaining = (int)(secondsRemaining / 3600);
secondsRemaining -= (hoursRemaining * 3600);
int minutesRemaining = (int)(secondsRemaining / 60);
secondsRemaining -= (minutesRemaining * 60);
lblHashrate.Text = String.Format("Hashrate: {0:N0} / second. Hashes per client(avg): {1:N0}", (ulong)hashesPerSecond, (ulong)(hashesPerSecond / mTheMan.mClients.Count));
}
}
private void protocol_SelectedIndexChanged(object sender, EventArgs e)
{
mTheMan.SetCurrency((ClientManager.Currency)protocol.SelectedItem);
}
}
}