Browse Source

API add 'Network Difficulty' to 'coin'

Conflicts:
	README.RPC
Kano 13 years ago
parent
commit
a2468ba1a3
4 changed files with 11 additions and 3 deletions
  1. 4 2
      README.RPC
  2. 1 0
      api.c
  3. 5 1
      miner.c
  4. 1 0
      miner.h

+ 4 - 2
README.RPC

@@ -305,7 +305,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
@@ -408,7 +409,7 @@ miner.php - an example web page to access the API
 Feature Changelog for external applications using the API:
 
 
-API V1.24b
+API V1.24.1
 
 Modified API commands:
  'cpustatus' - add 'ProcID'
@@ -419,6 +420,7 @@ Modified API commands:
  'devdetails' - add 'ProcID'
  'devdetail' - add 'Name', 'ID', and 'ProcID'
  'pools' - add 'Message'
+ 'coin' - add 'Network Difficulty'
 
 Pretty much updated every method returning 'Name' and 'ID' to also return
 'ProcID'. This is a number starting with 0 for 'a', 1 for 'b', etc.

+ 1 - 0
api.c

@@ -2871,6 +2871,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", &current_diff, true);
 
 	root = print_data(root, buf, isjson, false);
 	io_add(io_data, buf);

+ 5 - 1
miner.c

@@ -270,6 +270,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;
 
@@ -4508,12 +4509,15 @@ static int block_sort(struct block *blocka, struct block *blockb)
 static void set_blockdiff(const struct work *work)
 {
 	unsigned char target[32];
+	double diff;
 	uint64_t diff64;
 
 	real_block_target(target, work->data);
-	diff64 = target_diff(target);
+	diff = target_diff(target);
+	diff64 = diff;
 
 	suffix_string(diff64, block_diff, 0);
+	current_diff = diff;
 }
 
 static bool test_work_current(struct work *work)

+ 1 - 0
miner.h

@@ -880,6 +880,7 @@ extern int opt_fail_pause;
 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;