Commit 5c271efa68589c931cd2d8cdc5ad3b31b0f79787

Con Kolivas 2014-03-01T16:43:32

Make the cointerra displayed hashrate based on valid share generation.

diff --git a/driver-cointerra.c b/driver-cointerra.c
index d17c0aa..2e3911a 100644
--- a/driver-cointerra.c
+++ b/driver-cointerra.c
@@ -369,7 +369,7 @@ static void cta_parse_recvmatch(struct thr_info *thr, struct cgpu_info *cointerr
 
 			mutex_lock(&info->lock);
 			if (ret)
-				info->share_hashes += (uint64_t)work->work_difficulty * 0x100000000ull;
+				info->share_hashes = (uint64_t)work->work_difficulty * 0x100000000ull;
 			info->hashes += nonce;
 			mutex_unlock(&info->lock);
 		} else {
@@ -951,9 +951,10 @@ static int64_t cta_scanwork(struct thr_info *thr)
 	}
 
 	mutex_lock(&info->lock);
-	hashes = info->hashes;
-	info->tot_calc_hashes += hashes;
-	info->hashes = 0;
+	hashes = info->share_hashes;
+	info->tot_share_hashes += info->share_hashes;
+	info->tot_calc_hashes += info->hashes;
+	info->hashes = info->share_hashes = 0;
 	mutex_unlock(&info->lock);
 
 	if (unlikely(cointerra->usbinfo.nodev))
@@ -987,7 +988,7 @@ static void cta_zero_stats(struct cgpu_info *cointerra)
 
 	info->tot_calc_hashes = 0;
 	info->tot_reset_hashes = info->tot_hashes;
-	info->share_hashes = 0;
+	info->tot_share_hashes = 0;
 }
 
 static struct api_data *cta_api_stats(struct cgpu_info *cgpu)
@@ -1072,13 +1073,13 @@ static struct api_data *cta_api_stats(struct cgpu_info *cgpu)
 	root = api_add_uint64(root, "Hashrate", &ghs, true);
 	ghs = info->tot_hashes / dev_runtime;
 	root = api_add_uint64(root, "Raw hashrate", &ghs, true);
-	ghs = info->share_hashes / dev_runtime;
+	ghs = info->tot_share_hashes / dev_runtime;
 	root = api_add_uint64(root, "Share hashrate", &ghs, true);
 	root = api_add_uint64(root, "Total calc hashes", &info->tot_calc_hashes, false);
 	ghs = info->tot_hashes - info->tot_reset_hashes;
 	root = api_add_uint64(root, "Total hashes", &ghs, true);
 	root = api_add_uint64(root, "Total raw hashes", &info->tot_hashes, false);
-	root = api_add_uint64(root, "Total share hashes", &info->share_hashes, false);
+	root = api_add_uint64(root, "Total share hashes", &info->tot_share_hashes, false);
 	root = api_add_uint64(root, "Total flushed hashes", &info->tot_flushed_hashes, false);
 	val = cgpu->diff_accepted * 0x100000000ull;
 	root = api_add_uint64(root, "Accepted hashes", &val, true);
diff --git a/driver-cointerra.h b/driver-cointerra.h
index 523012e..d8344e8 100644
--- a/driver-cointerra.h
+++ b/driver-cointerra.h
@@ -201,6 +201,7 @@ struct cointerra_info {
 
 	/* Calculated totals based on shares returned */
 	uint64_t share_hashes;
+	uint64_t tot_share_hashes;
 	int requested;
 	uint16_t work_id;
 	int no_matching_work;