Browse Source

Report precise share difficulties below 1

Luke Dashjr 12 years ago
parent
commit
a74ba8b1d8
3 changed files with 11 additions and 11 deletions
  1. 2 2
      api.c
  2. 6 6
      miner.c
  3. 3 3
      miner.h

+ 2 - 2
api.c

@@ -1933,7 +1933,7 @@ static void poolstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
 			root = api_add_escape(root, "Stratum URL", pool->stratum_url, false);
 			root = api_add_escape(root, "Stratum URL", pool->stratum_url, false);
 		else
 		else
 			root = api_add_const(root, "Stratum URL", BLANK, false);
 			root = api_add_const(root, "Stratum URL", BLANK, false);
-		root = api_add_uint64(root, "Best Share", &(pool->best_diff), true);
+		root = api_add_diff(root, "Best Share", &(pool->best_diff), true);
 		if (pool->admin_msg)
 		if (pool->admin_msg)
 			root = api_add_escape(root, "Message", pool->admin_msg, true);
 			root = api_add_escape(root, "Message", pool->admin_msg, true);
 		double rejp = (pool->diff_accepted + pool->diff_rejected + pool->diff_stale) ?
 		double rejp = (pool->diff_accepted + pool->diff_rejected + pool->diff_stale) ?
@@ -2001,7 +2001,7 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
 	root = api_add_diff(root, "Difficulty Accepted", &(total_diff_accepted), true);
 	root = api_add_diff(root, "Difficulty Accepted", &(total_diff_accepted), true);
 	root = api_add_diff(root, "Difficulty Rejected", &(total_diff_rejected), true);
 	root = api_add_diff(root, "Difficulty Rejected", &(total_diff_rejected), true);
 	root = api_add_diff(root, "Difficulty Stale", &(total_diff_stale), true);
 	root = api_add_diff(root, "Difficulty Stale", &(total_diff_stale), true);
-	root = api_add_uint64(root, "Best Share", &(best_diff), true);
+	root = api_add_diff(root, "Best Share", &(best_diff), true);
 	double hwp = (total_bad_diff1 + total_diff1) ?
 	double hwp = (total_bad_diff1 + total_diff1) ?
 			(double)(total_bad_diff1) / (double)(total_bad_diff1 + total_diff1) : 0;
 			(double)(total_bad_diff1) / (double)(total_bad_diff1 + total_diff1) : 0;
 	root = api_add_percent(root, "Device Hardware%", &hwp, false);
 	root = api_add_percent(root, "Device Hardware%", &hwp, false);

+ 6 - 6
miner.c

@@ -366,7 +366,7 @@ static char best_share[8] = "0";
 double current_diff = 0xFFFFFFFFFFFFFFFFULL;
 double current_diff = 0xFFFFFFFFFFFFFFFFULL;
 static char block_diff[8];
 static char block_diff[8];
 static char net_hashrate[10];
 static char net_hashrate[10];
-uint64_t best_diff = 0;
+double best_diff = 0;
 
 
 static bool known_blkheight_current;
 static bool known_blkheight_current;
 static uint32_t known_blkheight;
 static uint32_t known_blkheight;
@@ -4070,14 +4070,14 @@ static void reject_pool(struct pool *pool)
 	pool->enabled = POOL_REJECTING;
 	pool->enabled = POOL_REJECTING;
 }
 }
 
 
-static uint64_t share_diff(const struct work *);
+static double share_diff(const struct work *);
 
 
 static
 static
 void share_result_msg(const struct work *work, const char *disp, const char *reason, bool resubmit, const char *worktime) {
 void share_result_msg(const struct work *work, const char *disp, const char *reason, bool resubmit, const char *worktime) {
 	struct cgpu_info *cgpu;
 	struct cgpu_info *cgpu;
 	const unsigned char *hashpart = &work->hash[opt_scrypt ? 26 : 24];
 	const unsigned char *hashpart = &work->hash[opt_scrypt ? 26 : 24];
 	char shrdiffdisp[16];
 	char shrdiffdisp[16];
-	int tgtdiff = floor(work->work_difficulty);
+	const double tgtdiff = work->work_difficulty;
 	char tgtdiffdisp[16];
 	char tgtdiffdisp[16];
 	char where[20];
 	char where[20];
 	
 	
@@ -4568,7 +4568,7 @@ static void calc_diff(struct work *work, int known)
 	difficulty = work->work_difficulty;
 	difficulty = work->work_difficulty;
 
 
 	pool_stats->last_diff = difficulty;
 	pool_stats->last_diff = difficulty;
-	suffix_string((uint64_t)difficulty, work->pool->diff, sizeof(work->pool->diff), 0);
+	suffix_string(difficulty, work->pool->diff, sizeof(work->pool->diff), 0);
 
 
 	if (difficulty == pool_stats->min_diff)
 	if (difficulty == pool_stats->min_diff)
 		pool_stats->min_diff_count++;
 		pool_stats->min_diff_count++;
@@ -5346,9 +5346,9 @@ bool stale_work(struct work *work, bool share)
 	return false;
 	return false;
 }
 }
 
 
-static uint64_t share_diff(const struct work *work)
+static double share_diff(const struct work *work)
 {
 {
-	uint64_t ret;
+	double ret;
 	bool new_best = false;
 	bool new_best = false;
 
 
 	ret = target_diff(work->hash);
 	ret = target_diff(work->hash);

+ 3 - 3
miner.h

@@ -1103,7 +1103,7 @@ extern int opt_log_interval;
 extern unsigned long long global_hashrate;
 extern unsigned long long global_hashrate;
 extern char *current_fullhash;
 extern char *current_fullhash;
 extern double current_diff;
 extern double current_diff;
-extern uint64_t best_diff;
+extern double best_diff;
 extern time_t block_time;
 extern time_t block_time;
 
 
 struct curl_ent {
 struct curl_ent {
@@ -1225,7 +1225,7 @@ struct pool {
 	struct timeval tv_last_work_time;
 	struct timeval tv_last_work_time;
 	time_t last_share_time;
 	time_t last_share_time;
 	double last_share_diff;
 	double last_share_diff;
-	uint64_t best_diff;
+	double best_diff;
 
 
 	struct cgminer_stats cgminer_stats;
 	struct cgminer_stats cgminer_stats;
 	struct cgminer_pool_stats cgminer_pool_stats;
 	struct cgminer_pool_stats cgminer_pool_stats;
@@ -1273,7 +1273,7 @@ struct work {
 	unsigned char	target[32];
 	unsigned char	target[32];
 	unsigned char	hash[32];
 	unsigned char	hash[32];
 
 
-	uint64_t	share_diff;
+	double share_diff;
 
 
 	int		rolls;
 	int		rolls;
 	int		drv_rolllimit; /* How much the driver can roll ntime */
 	int		drv_rolllimit; /* How much the driver can roll ntime */