Browse Source

Merge branch 'tui_income' into bfgminer

Luke Dashjr 12 years ago
parent
commit
dfbe11db91
2 changed files with 51 additions and 13 deletions
  1. 3 2
      README
  2. 48 11
      miner.c

+ 3 - 2
README

@@ -427,7 +427,7 @@ difficulty (including the network hashrate that difficulty represents), and when
 the search for the new block started.
 the search for the new block started.
 
 
 The BFGMiner status line shows:
 The BFGMiner status line shows:
- ST:1  F:0  NB:1  AS:0  BW:[ 75/241 B/s]  E:2.42  U:22.53/m  BS:2.71k
+ ST:1  F:0  NB:1  AS:0  BW:[ 75/241 B/s]  E:2.42  I:12.99mBTC/hr  BS:2.71k
 
 
 ST is STaged work items (ready to use).
 ST is STaged work items (ready to use).
 F  is network Failure occasions (server down or slow to provide work)
 F  is network Failure occasions (server down or slow to provide work)
@@ -436,7 +436,8 @@ AS is Active Submissions (shares in the process of submitting)
 BW is BandWidth usage on the network (received/sent)
 BW is BandWidth usage on the network (received/sent)
 E  is Efficiency defined as number of shares accepted (multiplied by their
 E  is Efficiency defined as number of shares accepted (multiplied by their
           difficulty) per 2 KB of bandwidth
           difficulty) per 2 KB of bandwidth
-U  is Utility defined as the number of shares / minute
+I  is expected Income, calculated by actual shares submitted in 100% PPS value
+          (assumes Bitcoin, does not account for altcoin conversions!)
 BS is the all time Best Share difficulty you've found
 BS is the all time Best Share difficulty you've found
 
 
 The totals line shows the following:
 The totals line shows the following:

+ 48 - 11
miner.c

@@ -341,6 +341,7 @@ uint64_t best_diff = 0;
 static bool known_blkheight_current;
 static bool known_blkheight_current;
 static uint32_t known_blkheight;
 static uint32_t known_blkheight;
 static uint32_t known_blkheight_blkid;
 static uint32_t known_blkheight_blkid;
+static uint64_t block_subsidy;
 
 
 struct block {
 struct block {
 	char hash[40];
 	char hash[40];
@@ -2233,6 +2234,7 @@ void have_block_height(uint32_t block_id, uint32_t blkheight)
 	cg_wlock(&ch_lock);
 	cg_wlock(&ch_lock);
 	known_blkheight = blkheight;
 	known_blkheight = blkheight;
 	known_blkheight_blkid = block_id;
 	known_blkheight_blkid = block_id;
+	block_subsidy = 5000000000LL >> (blkheight / 210000);
 	if (block_id == current_block_id)
 	if (block_id == current_block_id)
 		__update_block_title(NULL);
 		__update_block_title(NULL);
 	cg_wunlock(&ch_lock);
 	cg_wunlock(&ch_lock);
@@ -2629,12 +2631,20 @@ utility_to_hashrate(double utility)
 	return utility * 0x4444444;
 	return utility * 0x4444444;
 }
 }
 
 
-static const char*_unitchar = " kMGTPEZY?";
+static const char*_unitchar = "pn\xb5m kMGTPEZY?";
 
 
 static
 static
 void pick_unit(float hashrate, unsigned char *unit)
 void pick_unit(float hashrate, unsigned char *unit)
 {
 {
 	unsigned char i;
 	unsigned char i;
+	
+	if (hashrate == 0)
+	{
+		*unit = 2;
+		return;
+	}
+	
+	hashrate *= 1e12;
 	for (i = 0; i < *unit; ++i)
 	for (i = 0; i < *unit; ++i)
 		hashrate /= 1e3;
 		hashrate /= 1e3;
 	
 	
@@ -2655,8 +2665,14 @@ enum h2bs_fmt {
 };
 };
 static const size_t h2bs_fmt_size[] = {6, 10, 11};
 static const size_t h2bs_fmt_size[] = {6, 10, 11};
 
 
+enum bfu_floatprec {
+	FUP_INTEGER,
+	FUP_HASHES,
+	FUP_BTC,
+};
+
 static
 static
-int format_unit2(char *buf, size_t sz, bool floatprec, const char *measurement, enum h2bs_fmt fmt, float hashrate, signed char unitin)
+int format_unit3(char *buf, size_t sz, enum bfu_floatprec fprec, const char *measurement, enum h2bs_fmt fmt, float hashrate, signed char unitin)
 {
 {
 	char *s = buf;
 	char *s = buf;
 	unsigned char prec, i, unit;
 	unsigned char prec, i, unit;
@@ -2670,20 +2686,31 @@ int format_unit2(char *buf, size_t sz, bool floatprec, const char *measurement,
 	else
 	else
 		unit = unitin;
 		unit = unitin;
 	
 	
+	hashrate *= 1e12;
+	
 	for (i = 0; i < unit; ++i)
 	for (i = 0; i < unit; ++i)
 		hashrate /= 1000;
 		hashrate /= 1000;
 	
 	
-	if (floatprec)
+	switch (fprec)
 	{
 	{
+	case FUP_HASHES:
 		// 100 but with tolerance for floating-point rounding, max "99.99" then "100.0"
 		// 100 but with tolerance for floating-point rounding, max "99.99" then "100.0"
-		if (hashrate >= 99.995 || unit < 2)
+		if (hashrate >= 99.995 || unit < 6)
 			prec = 1;
 			prec = 1;
 		else
 		else
 			prec = 2;
 			prec = 2;
 		_SNP("%5.*f", prec, hashrate);
 		_SNP("%5.*f", prec, hashrate);
-	}
-	else
+		break;
+	case FUP_INTEGER:
 		_SNP("%3d", (int)hashrate);
 		_SNP("%3d", (int)hashrate);
+		break;
+	case FUP_BTC:
+		if (hashrate >= 99.995)
+			prec = 0;
+		else
+			prec = 2;
+		_SNP("%5.*f", prec, hashrate);
+	}
 	
 	
 	switch (fmt) {
 	switch (fmt) {
 	case H2B_SPACED:
 	case H2B_SPACED:
@@ -2696,6 +2723,8 @@ int format_unit2(char *buf, size_t sz, bool floatprec, const char *measurement,
 	
 	
 	return rv;
 	return rv;
 }
 }
+#define format_unit2(buf, sz, floatprec, measurement, fmt, n, unit)  \
+	format_unit3(buf, sz, floatprec ? FUP_HASHES : FUP_INTEGER, measurement, fmt, n, unit)
 
 
 static
 static
 char *_multi_format_unit(char **buflist, size_t *bufszlist, bool floatprec, const char *measurement, enum h2bs_fmt fmt, const char *delim, int count, const float *numbers, bool isarray)
 char *_multi_format_unit(char **buflist, size_t *bufszlist, bool floatprec, const char *measurement, enum h2bs_fmt fmt, const char *delim, int count, const float *numbers, bool isarray)
@@ -3117,6 +3146,13 @@ def:
 			case '\xb0':  // Degrees symbol
 			case '\xb0':  // Degrees symbol
 				buf[0] = ((unsigned char *)p)[0];
 				buf[0] = ((unsigned char *)p)[0];
 #endif
 #endif
+			case '\xb5':  // Mu (SI prefix micro-)
+#ifdef USE_UNICODE
+				if (use_unicode)
+					buf[0] = ((unsigned char *)p)[0];
+				else
+#endif
+					buf[0] = 'u';
 		}
 		}
 		PREP_ADDCH;
 		PREP_ADDCH;
 #ifdef USE_UNICODE
 #ifdef USE_UNICODE
@@ -3162,7 +3198,7 @@ static void curses_print_status(const int ts)
 	struct pool *pool = currentpool;
 	struct pool *pool = currentpool;
 	struct timeval now, tv;
 	struct timeval now, tv;
 	float efficiency;
 	float efficiency;
-	double utility;
+	double income;
 	int logdiv;
 	int logdiv;
 
 
 	efficiency = total_bytes_xfer ? total_diff_accepted * 2048. / total_bytes_xfer : 0.0;
 	efficiency = total_bytes_xfer ? total_diff_accepted * 2048. / total_bytes_xfer : 0.0;
@@ -3193,10 +3229,11 @@ static void curses_print_status(const int ts)
 	bfg_waddstr(statuswin, statusline);
 	bfg_waddstr(statuswin, statusline);
 	wclrtoeol(statuswin);
 	wclrtoeol(statuswin);
 
 
-	utility = total_accepted / total_secs * 60;
+	income = total_diff_accepted * 3600 * block_subsidy / total_secs / current_diff;
 
 
-	char bwstr[12];
-	cg_mvwprintw(statuswin, 4, 0, " ST:%d  F:%d  NB:%d  AS:%d  BW:[%s]  E:%.2f  U:%.1f/m  BS:%s",
+	char bwstr[12], incomestr[13];
+	format_unit3(incomestr, sizeof(incomestr), FUP_BTC, "BTC/hr", H2B_SHORT, income/1e8, -1);
+	cg_mvwprintw(statuswin, 4, 0, " ST:%d  F:%d  NB:%d  AS:%d  BW:[%s]  E:%.2f  I:%s  BS:%s",
 		ts,
 		ts,
 		total_go + total_ro,
 		total_go + total_ro,
 		new_blocks,
 		new_blocks,
@@ -3206,7 +3243,7 @@ static void curses_print_status(const int ts)
 		                  (float)(total_bytes_rcvd / total_secs),
 		                  (float)(total_bytes_rcvd / total_secs),
 		                  (float)(total_bytes_sent / total_secs)),
 		                  (float)(total_bytes_sent / total_secs)),
 		efficiency,
 		efficiency,
-		utility,
+		incomestr,
 		best_share);
 		best_share);
 	wclrtoeol(statuswin);
 	wclrtoeol(statuswin);
 	if ((pool_strategy == POOL_LOADBALANCE  || pool_strategy == POOL_BALANCE) && total_pools > 1) {
 	if ((pool_strategy == POOL_LOADBALANCE  || pool_strategy == POOL_BALANCE) && total_pools > 1) {