Browse Source

inc_hw_errors2 function can handle a bad nonce without a known work

Luke Dashjr 12 years ago
parent
commit
a99d509b33
2 changed files with 12 additions and 5 deletions
  1. 11 5
      miner.c
  2. 1 0
      miner.h

+ 11 - 5
miner.c

@@ -7820,22 +7820,23 @@ static void submit_work_async(struct work *work_in, struct timeval *tv_work_foun
 	_submit_work_async(work);
 }
 
-void inc_hw_errors(struct thr_info *thr, const struct work *work, const uint32_t bad_nonce)
+void inc_hw_errors2(struct thr_info *thr, const struct work *work, const uint32_t *bad_nonce_p)
 {
 	struct cgpu_info * const cgpu = thr->cgpu;
 	
-	if (work)
+	if (bad_nonce_p)
 		applog(LOG_DEBUG, "%"PRIpreprv": invalid nonce (%08lx) - HW error",
-		       cgpu->proc_repr, (unsigned long)be32toh(bad_nonce));
+		       cgpu->proc_repr, (unsigned long)be32toh(*bad_nonce_p));
 	
 	mutex_lock(&stats_lock);
 	hw_errors++;
 	++cgpu->hw_errors;
-	if (work)
+	if (bad_nonce_p)
 	{
 		++total_diff1;
 		++cgpu->diff1;
-		++work->pool->diff1;
+		if (work)
+			++work->pool->diff1;
 		++total_bad_nonces;
 		++cgpu->bad_nonces;
 	}
@@ -7845,6 +7846,11 @@ void inc_hw_errors(struct thr_info *thr, const struct work *work, const uint32_t
 		thr->cgpu->drv->hw_error(thr);
 }
 
+void inc_hw_errors(struct thr_info *thr, const struct work *work, const uint32_t bad_nonce)
+{
+	inc_hw_errors2(thr, work, work ? &bad_nonce : NULL);
+}
+
 enum test_nonce2_result hashtest2(struct work *work, bool checktarget)
 {
 	uint32_t *hash2_32 = (uint32_t *)&work->hash[0];

+ 1 - 0
miner.h

@@ -1276,6 +1276,7 @@ struct work {
 
 extern void get_datestamp(char *, time_t);
 #define get_now_datestamp(buf)  get_datestamp(buf, INVALID_TIMESTAMP)
+extern void inc_hw_errors2(struct thr_info *thr, const struct work *work, const uint32_t *bad_nonce_p);
 extern void inc_hw_errors(struct thr_info *, const struct work *, const uint32_t bad_nonce);
 #define inc_hw_errors_only(thr)  inc_hw_errors(thr, NULL, 0)
 enum test_nonce2_result {