Browse Source

Refactor diff1 records to properly weigh non-diff1 work

Conflicts:
	miner.c
Luke Dashjr 12 years ago
parent
commit
a8fdcc77e4
3 changed files with 18 additions and 18 deletions
  1. 4 4
      api.c
  2. 9 9
      miner.c
  3. 5 5
      miner.h

+ 4 - 4
api.c

@@ -1476,7 +1476,7 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 	enum alive status = cgpu->status;
 	float temp = -1;
 	int accepted = 0, rejected = 0, stale = 0, hw_errors = 0;
-	int diff1 = 0, bad_nonces = 0;
+	double diff1 = 0, bad_nonces = 0;
 	double diff_accepted = 0, diff_rejected = 0, diff_stale = 0;
 	int last_share_pool = -1;
 	time_t last_share_pool_time = -1, last_device_valid_work = -1;
@@ -1540,7 +1540,7 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 	}
 	root = api_add_mhtotal(root, "Total MH", &total_mhashes, false);
 	double work_utility = diff1 / runtime * 60;
-	root = api_add_int(root, "Diff1 Work", &diff1, false);
+	root = api_add_diff(root, "Diff1 Work", &diff1, false);
 	root = api_add_utility(root, "Work Utility", &work_utility, false);
 	root = api_add_diff(root, "Difficulty Accepted", &diff_accepted, false);
 	root = api_add_diff(root, "Difficulty Rejected", &diff_rejected, false);
@@ -1971,7 +1971,7 @@ static void poolstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
 		root = api_add_uint(root, "Remote Failures", &(pool->remotefail_occasions), false);
 		root = api_add_escape(root, "User", pool->rpc_user, false);
 		root = api_add_time(root, "Last Share Time", &(pool->last_share_time), false);
-		root = api_add_int(root, "Diff1 Shares", &(pool->diff1), false);
+		root = api_add_diff(root, "Diff1 Shares", &(pool->diff1), false);
 		if (pool->rpc_proxy) {
 			root = api_add_escape(root, "Proxy", pool->rpc_proxy, false);
 		} else {
@@ -2050,7 +2050,7 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
 	root = api_add_uint(root, "Remote Failures", &(total_ro), true);
 	root = api_add_uint(root, "Network Blocks", &(new_blocks), true);
 	root = api_add_mhtotal(root, "Total MH", &(total_mhashes_done), true);
-	root = api_add_int(root, "Diff1 Work", &total_diff1, true);
+	root = api_add_diff(root, "Diff1 Work", &total_diff1, true);
 	root = api_add_utility(root, "Work Utility", &(work_utility), false);
 	root = api_add_diff(root, "Difficulty Accepted", &(total_diff_accepted), true);
 	root = api_add_diff(root, "Difficulty Rejected", &(total_diff_rejected), true);

+ 9 - 9
miner.c

@@ -276,10 +276,10 @@ static struct work *submit_waiting;
 notifier_t submit_waiting_notifier;
 
 int hw_errors;
-int total_accepted, total_rejected, total_diff1;
-int total_bad_nonces;
+int total_accepted, total_rejected;
 int total_getworks, total_stale, total_discarded;
 uint64_t total_bytes_rcvd, total_bytes_sent;
+double total_diff1, total_bad_nonces;
 double total_diff_accepted, total_diff_rejected, total_diff_stale;
 static int staged_rollable;
 unsigned int new_blocks;
@@ -3108,8 +3108,8 @@ void get_statline3(char *buf, size_t bufsz, struct cgpu_info *cgpu, bool for_cur
 	double waccepted = cgpu->diff_accepted;
 	double wnotaccepted = cgpu->diff_rejected + cgpu->diff_stale;
 	int hwerrs = cgpu->hw_errors;
-	int badnonces = cgpu->bad_nonces;
-	int goodnonces = cgpu->diff1;
+	double badnonces = cgpu->bad_nonces;
+	double goodnonces = cgpu->diff1;
 	
 	if (!opt_show_procs)
 	{
@@ -8604,8 +8604,8 @@ void inc_hw_errors2(struct thr_info *thr, const struct work *work, const uint32_
 	++cgpu->hw_errors;
 	if (bad_nonce_p)
 	{
-		++total_bad_nonces;
-		++cgpu->bad_nonces;
+		total_bad_nonces += work->work_difficulty;
+		cgpu->bad_nonces += work->work_difficulty;
 	}
 	mutex_unlock(&stats_lock);
 
@@ -8677,9 +8677,9 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 		}
 	
 	mutex_lock(&stats_lock);
-	total_diff1++;
-	thr->cgpu->diff1++;
-	work->pool->diff1++;
+	total_diff1       += work->work_difficulty;
+	thr ->cgpu->diff1 += work->work_difficulty;
+	work->pool->diff1 += work->work_difficulty;
 	thr->cgpu->last_device_valid_work = time(NULL);
 	mutex_unlock(&stats_lock);
 	

+ 5 - 5
miner.h

@@ -499,7 +499,7 @@ struct cgpu_info {
 	int accepted;
 	int rejected;
 	int stale;
-	int bad_nonces;
+	double bad_nonces;
 	int hw_errors;
 	double rolling;
 	double total_mhashes;
@@ -555,7 +555,7 @@ struct cgpu_info {
 	int gpu_powertune;
 	float gpu_vddc;
 #endif
-	int diff1;
+	double diff1;
 	double diff_accepted;
 	double diff_rejected;
 	double diff_stale;
@@ -1098,11 +1098,11 @@ extern double total_rolling;
 extern double total_mhashes_done;
 extern unsigned int new_blocks;
 extern unsigned int found_blocks;
-extern int total_accepted, total_rejected, total_diff1;;
-extern int total_bad_nonces;
+extern int total_accepted, total_rejected;
 extern int total_getworks, total_stale, total_discarded;
 extern uint64_t total_bytes_rcvd, total_bytes_sent;
 #define total_bytes_xfer (total_bytes_rcvd + total_bytes_sent)
+extern double total_diff1, total_bad_nonces;
 extern double total_diff_accepted, total_diff_rejected, total_diff_stale;
 extern unsigned int local_work;
 extern unsigned int total_go, total_ro;
@@ -1204,7 +1204,7 @@ struct pool {
 	int seq_rejects;
 	int seq_getfails;
 	int solved;
-	int diff1;
+	double diff1;
 	char diff[8];
 	int quota;
 	int quota_gcd;