API - Add last share difficulty for devices and pool
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
diff --git a/API-README b/API-README
index ad89b1f..d0653d4 100644
--- a/API-README
+++ b/API-README
@@ -392,13 +392,15 @@ Added API commands:
Modified API commands:
Change pool field name 'Diff1 Shares' to 'Diff1 Work'
- 'devs' - add 'Diff1 Work', 'Difficulty Accepted', 'Difficulty Rejected'
- to all devices
- 'gpu|N' - add 'Diff1 Work', 'Difficulty Accepted', 'Difficulty Rejected'
- 'pga|N' - add 'Diff1 Work', 'Difficulty Accepted', 'Difficulty Rejected'
+ 'devs' - add 'Diff1 Work', 'Difficulty Accepted', 'Difficulty Rejected',
+ 'Last Share Difficulty' to all devices
+ 'gpu|N' - add 'Diff1 Work', 'Difficulty Accepted',
+ 'Difficulty Rejected', 'Last Share Difficulty'
+ 'pga|N' - add 'Diff1 Work', 'Difficulty Accepted',
+ 'Difficulty Rejected', 'Last Share Difficulty'
'notify' - add '*Dev Throttle' (for BFL Singles)
- 'pools' - add 'Proxy Type', 'Proxy', 'Difficulty Accepted',
- 'Difficulty Rejected', 'Difficulty Stale'
+ 'pools' - add 'Proxy Type', 'Proxy', 'Difficulty Accepted', 'Difficulty Rejected',
+ 'Difficulty Stale', 'Last Share Difficulty'
'config' - add 'Queue', 'Expiry'
----------
diff --git a/api.c b/api.c
index 9b4e017..ec07b44 100644
--- a/api.c
+++ b/api.c
@@ -1387,6 +1387,7 @@ static void gpustatus(int gpu, bool isjson)
root = api_add_int(root, "Diff1 Work", &(cgpu->diff1), false);
root = api_add_diff(root, "Difficulty Accepted", &(cgpu->diff_accepted), false);
root = api_add_diff(root, "Difficulty Rejected", &(cgpu->diff_rejected), false);
+ root = api_add_diff(root, "Last Share Difficulty", &(cgpu->last_share_diff), false);
root = print_data(root, buf, isjson);
strcat(io_buffer, buf);
@@ -1473,6 +1474,7 @@ static void pgastatus(int pga, bool isjson)
root = api_add_int(root, "Diff1 Work", &(cgpu->diff1), false);
root = api_add_diff(root, "Difficulty Accepted", &(cgpu->diff_accepted), false);
root = api_add_diff(root, "Difficulty Rejected", &(cgpu->diff_rejected), false);
+ root = api_add_diff(root, "Last Share Difficulty", &(cgpu->last_share_diff), false);
root = print_data(root, buf, isjson);
strcat(io_buffer, buf);
@@ -1508,6 +1510,7 @@ static void cpustatus(int cpu, bool isjson)
root = api_add_int(root, "Diff1 Work", &(cgpu->diff1), false);
root = api_add_diff(root, "Difficulty Accepted", &(cgpu->diff_accepted), false);
root = api_add_diff(root, "Difficulty Rejected", &(cgpu->diff_rejected), false);
+ root = api_add_diff(root, "Last Share Difficulty", &(cgpu->last_share_diff), false);
root = print_data(root, buf, isjson);
strcat(io_buffer, buf);
@@ -1890,6 +1893,7 @@ static void poolstatus(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
root = api_add_diff(root, "Difficulty Accepted", &(pool->diff_accepted), false);
root = api_add_diff(root, "Difficulty Rejected", &(pool->diff_rejected), false);
root = api_add_diff(root, "Difficulty Stale", &(pool->diff_stale), false);
+ root = api_add_diff(root, "Last Share Difficulty", &(pool->last_share_diff), false);
if (isjson && (i > 0))
strcat(io_buffer, COMMA);
diff --git a/cgminer.c b/cgminer.c
index cb61958..90bc4a8 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1877,7 +1877,9 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
pool->seq_rejects = 0;
cgpu->last_share_pool = pool->pool_no;
cgpu->last_share_pool_time = time(NULL);
+ cgpu->last_share_diff = work->work_difficulty;
pool->last_share_time = cgpu->last_share_pool_time;
+ pool->last_share_diff = work->work_difficulty;
applog(LOG_DEBUG, "PROOF OF WORK RESULT: true (yay!!!)");
if (!QUIET) {
if (total_pools > 1)
diff --git a/miner.h b/miner.h
index b94645e..d558bad 100644
--- a/miner.h
+++ b/miner.h
@@ -405,6 +405,7 @@ struct cgpu_info {
double diff_rejected;
int last_share_pool;
time_t last_share_pool_time;
+ double last_share_diff;
time_t device_last_well;
time_t device_last_not_well;
@@ -800,6 +801,7 @@ struct pool {
struct list_head curlring;
time_t last_share_time;
+ double last_share_diff;
struct cgminer_stats cgminer_stats;
struct cgminer_pool_stats cgminer_pool_stats;