Commit 03f626e68d1a90fde0441cf39d932238bf0edab6

Kano 2013-01-02T21:51:09

Remember best share per pool and return in API pools

diff --git a/API-README b/API-README
index b205c90..a71b694 100644
--- a/API-README
+++ b/API-README
@@ -400,7 +400,14 @@ miner.php - an example web page to access the API
 Feature Changelog for external applications using the API:
 
 
-API V1.23
+API V1.24
+
+Modified API commands:
+ 'pools' - add 'Best Share'
+
+----------
+
+API V1.23 (cgminer v2.10.2)
 
 Added API commands:
  'pgaset' - with: MMQ opt=clock val=160 to 230 (and a multiple of 2)
diff --git a/api.c b/api.c
index 659d934..94b1d5c 100644
--- a/api.c
+++ b/api.c
@@ -1993,6 +1993,7 @@ static void poolstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
 		else
 			root = api_add_const(root, "Stratum URL", BLANK, false);
 		root = api_add_bool(root, "Has GBT", &(pool->has_gbt), false);
+		root = api_add_uint64(root, "Best Share", &(pool->best_diff), true);
 
 		root = print_data(root, buf, isjson, isjson && (i > 0));
 		io_add(io_data, buf);
diff --git a/cgminer.c b/cgminer.c
index 876abed..b33bb7f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2349,6 +2349,8 @@ static uint64_t share_diff(const struct work *work)
 		best_diff = ret;
 		suffix_string(best_diff, best_share, 0);
 	}
+	if (ret > work->pool->best_diff)
+		work->pool->best_diff = ret;
 	mutex_unlock(&control_lock);
 	return ret;
 }
diff --git a/miner.h b/miner.h
index df2888e..79a4cf2 100644
--- a/miner.h
+++ b/miner.h
@@ -920,6 +920,7 @@ struct pool {
 
 	time_t last_share_time;
 	double last_share_diff;
+	uint64_t best_diff;
 
 	struct cgminer_stats cgminer_stats;
 	struct cgminer_pool_stats cgminer_pool_stats;