API add 'Network Difficulty' to 'coin'
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
diff --git a/API-README b/API-README
index de6233c..360d4ad 100644
--- a/API-README
+++ b/API-README
@@ -306,7 +306,8 @@ The list of requests - a (*) means it requires privileged access - and replies a
Hash Method=sha256/scrypt,
Current Block Time=N.N, <- 0 means none
Current Block Hash=XXXX..., <- blank if none
- LP=true/false| <- LP is in use on at least 1 pool
+ LP=true/false, <- LP is in use on at least 1 pool
+ Network Difficulty=NN.NN|
debug|setting (*)
DEBUG Debug settings
@@ -430,6 +431,7 @@ Added API commands:
Modified API commands:
'devs' 'gpu' and 'pga' - add 'Last Valid Work'
'config' - add 'Hotplug'
+ 'coin' - add 'Network Difficulty'
----------
diff --git a/api.c b/api.c
index 72763f1..2f169ed 100644
--- a/api.c
+++ b/api.c
@@ -3210,6 +3210,7 @@ static void minecoin(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __may
mutex_unlock(&ch_lock);
root = api_add_bool(root, "LP", &have_longpoll, false);
+ root = api_add_diff(root, "Network Difficulty", ¤t_diff, true);
root = print_data(root, buf, isjson, false);
io_add(io_data, buf);
diff --git a/cgminer.c b/cgminer.c
index 7fac74b..f9eef42 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -232,6 +232,7 @@ static char datestamp[40];
static char blocktime[32];
struct timeval block_timeval;
static char best_share[8] = "0";
+double current_diff;
static char block_diff[8];
uint64_t best_diff = 0;
@@ -3607,6 +3608,7 @@ static void set_blockdiff(const struct work *work)
diff64 = diffone / d64;
suffix_string(diff64, block_diff, 0);
+ current_diff = (double)diffone / (double)d64;
}
static bool test_work_current(struct work *work)
diff --git a/miner.h b/miner.h
index 6f1b165..9fc32e6 100644
--- a/miner.h
+++ b/miner.h
@@ -844,6 +844,7 @@ extern const int opt_cutofftemp;
extern int opt_log_interval;
extern unsigned long long global_hashrate;
extern char *current_fullhash;
+extern double current_diff;
extern uint64_t best_diff;
extern struct timeval block_timeval;