Browse Source

API V1.25 - add 'Last Valid Work' time for each device

Conflicts:
	README.RPC
	api.c
	miner.c
Kano 13 years ago
parent
commit
a0cb03ec46
4 changed files with 24 additions and 6 deletions
  1. 9 0
      README.RPC
  2. 2 1
      api.c
  3. 12 5
      miner.c
  4. 1 0
      miner.h

+ 9 - 0
README.RPC

@@ -140,6 +140,8 @@ The list of requests - a (*) means it requires privileged access - and replies a
                               Last Share Time=NNN, <- standard long time in seconds
                                (or 0 if none) of last accepted share
                               Last Share Pool=N, <- pool number (or -1 if none)
+                              Last Valid Work=NNN, <- standand long time in seconds
+                               of last work returned that wasn't an HW:
                               Will not report PGAs if PGA mining is disabled
                               Will not report CPUs if CPU mining is disabled
 
@@ -414,6 +416,13 @@ api-example.py - a Python script to access the API
 Feature Changelog for external applications using the API:
 
 
+API V1.25
+
+Modified API commands:
+ 'devs' 'gpu' and 'pga' - add 'Last Valid Work'
+
+----------
+
 API V1.24.1 (BFGMiner v3.0.0)
 
 Modified API commands:

+ 2 - 1
api.c

@@ -134,7 +134,7 @@ static const char SEPARATOR = '|';
 #define SEPSTR "|"
 static const char GPUSEP = ',';
 
-static const char *APIVERSION = "1.24";
+static const char *APIVERSION = "1.25";
 static const char *DEAD = "Dead";
 static const char *SICK = "Sick";
 static const char *NOSTART = "NoStart";
@@ -1540,6 +1540,7 @@ static void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	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 = api_add_time(root, "Last Valid Work", &(cgpu->last_device_valid_work), false);
 
 	if (cgpu->api->get_api_extra_device_status)
 		root = api_add_extra(root, cgpu->api->get_api_extra_device_status(cgpu));

+ 12 - 5
miner.c

@@ -6797,6 +6797,7 @@ void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 	uint32_t *work_nonce = (uint32_t *)(work->data + 64 + 12);
 	uint32_t bak_nonce = *work_nonce;
 	struct timeval tv_work_found;
+	enum test_nonce2_result res;
 
 	gettimeofday(&tv_work_found, NULL);
 	*work_nonce = htole32(nonce);
@@ -6809,8 +6810,9 @@ void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 
 	/* Do one last check before attempting to submit the work */
 	/* Side effect: sets work->data for us */
-	switch (test_nonce2(work, nonce)) {
-		case TNR_BAD:
+	res = test_nonce2(work, nonce);
+	
+	if (unlikely(res == TNR_BAD))
 		{
 			struct cgpu_info *cgpu = thr->cgpu;
 			applog(LOG_WARNING, "%"PRIpreprv": invalid nonce - HW error",
@@ -6824,15 +6826,20 @@ void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 				thr->cgpu->api->hw_error(thr);
 			goto out;
 		}
-		case TNR_HIGH:
+	
+	mutex_lock(&stats_lock);
+	thr->cgpu->last_device_valid_work = time(NULL);
+	mutex_unlock(&stats_lock);
+	
+	if (res == TNR_HIGH)
+	{
 			// Share above target, normal
 			/* Check the diff of the share, even if it didn't reach the
 			 * target, just to set the best share value if it's higher. */
 			share_diff(work);
 			goto out;
-		case TNR_GOOD:
-			break;
 	}
+	
 	submit_work_async(work, &tv_work_found);
 out:
 	*work_nonce = bak_nonce;

+ 1 - 0
miner.h

@@ -502,6 +502,7 @@ struct cgpu_info {
 	int last_share_pool;
 	time_t last_share_pool_time;
 	double last_share_diff;
+	time_t last_device_valid_work;
 
 	time_t device_last_well;
 	time_t device_last_not_well;