Browse Source

Refactor diff1 records to properly weigh non-diff1 work

Luke Dashjr 12 years ago
parent
commit
86a9237f8e
3 changed files with 18 additions and 17 deletions
  1. 4 4
      api.c
  2. 9 8
      miner.c
  3. 5 5
      miner.h

+ 4 - 4
api.c

@@ -1513,7 +1513,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;
@@ -1577,7 +1577,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);
@@ -2009,7 +2009,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 {
@@ -2088,7 +2088,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 - 8
miner.c

@@ -277,10 +277,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;
@@ -3338,7 +3338,8 @@ void get_statline3(char *buf, size_t bufsz, struct cgpu_info *cgpu, bool for_cur
 	int accepted, rejected, stale;
 	double waccepted;
 	double wnotaccepted;
-	int hwerrs, badnonces, goodnonces;
+	int hwerrs;
+	double badnonces, goodnonces;
 	
 	rolling = mhashes = waccepted = wnotaccepted = 0;
 	accepted = rejected = stale = hwerrs = badnonces = goodnonces = 0;
@@ -8944,8 +8945,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);
 
@@ -9029,9 +9030,9 @@ bool submit_noffset_nonce(struct thr_info *thr, struct work *work_in, uint32_t n
 		}
 	
 	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;
@@ -1121,11 +1121,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;
@@ -1227,7 +1227,7 @@ struct pool {
 	int seq_rejects;
 	int seq_getfails;
 	int solved;
-	int diff1;
+	double diff1;
 	char diff[8];
 	int quota;
 	int quota_gcd;