API stats add some pool getwork difficulty stats
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
diff --git a/API-README b/API-README
index 6d0dda0..a1c54c5 100644
--- a/API-README
+++ b/API-README
@@ -401,6 +401,8 @@ Modified API commands:
'pools' - add 'Proxy Type', 'Proxy', 'Difficulty Accepted', 'Difficulty Rejected',
'Difficulty Stale', 'Last Share Difficulty'
'config' - add 'Queue', 'Expiry'
+ 'stats' - add 'Work Diff', 'Min Diff', 'Max Diff', 'Min Diff Count',
+ 'Max Diff Count' to the pool stats
----------
diff --git a/api.c b/api.c
index 0b6d54d..8ebf94d 100644
--- a/api.c
+++ b/api.c
@@ -2789,6 +2789,11 @@ static int itemstats(int i, char *id, struct cgminer_stats *stats, struct cgmine
root = api_add_bool(root, "Work Can Roll", &(pool_stats->canroll), false);
root = api_add_bool(root, "Work Had Expire", &(pool_stats->hadexpire), false);
root = api_add_uint32(root, "Work Roll Time", &(pool_stats->rolltime), false);
+ root = api_add_diff(root, "Work Diff", &(pool_stats->last_diff), false);
+ root = api_add_diff(root, "Min Diff", &(pool_stats->min_diff), false);
+ root = api_add_diff(root, "Max Diff", &(pool_stats->max_diff), false);
+ root = api_add_uint32(root, "Min Diff Count", &(pool_stats->min_diff_count), false);
+ root = api_add_uint32(root, "Max Diff Count", &(pool_stats->max_diff_count), false);
}
if (extra)
diff --git a/cgminer.c b/cgminer.c
index bb522f3..46806af 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2047,6 +2047,7 @@ static double DIFFEXACTONE = 269599466671506397946670150870196306736371444225405
*/
static void calc_diff(struct work *work)
{
+ struct cgminer_pool_stats *pool_stats = &(work->pool->cgminer_pool_stats);
double targ;
int i;
@@ -2057,6 +2058,22 @@ static void calc_diff(struct work *work)
}
work->work_difficulty = DIFFEXACTONE / (targ ? : DIFFEXACTONE);
+
+ pool_stats->last_diff = work->work_difficulty;
+
+ if (work->work_difficulty == pool_stats->min_diff)
+ pool_stats->min_diff_count++;
+ else if (work->work_difficulty < pool_stats->min_diff || pool_stats->min_diff == 0) {
+ pool_stats->min_diff = work->work_difficulty;
+ pool_stats->min_diff_count = 1;
+ }
+
+ if (work->work_difficulty == pool_stats->max_diff)
+ pool_stats->max_diff_count++;
+ else if (work->work_difficulty > pool_stats->max_diff) {
+ pool_stats->max_diff = work->work_difficulty;
+ pool_stats->max_diff_count = 1;
+ }
}
static void get_benchmark_work(struct work *work)
diff --git a/miner.h b/miner.h
index ede389a..169c9ee 100644
--- a/miner.h
+++ b/miner.h
@@ -314,6 +314,11 @@ struct cgminer_pool_stats {
bool canroll;
bool hadexpire;
uint32_t rolltime;
+ double min_diff;
+ double max_diff;
+ double last_diff;
+ uint32_t min_diff_count;
+ uint32_t max_diff_count;
};
struct cgpu_info {