Browse Source

Merge branch 'kanoi_english' into myfork

Conflicts:
	driver-icarus.c
Luke Dashjr 13 years ago
parent
commit
414a225a21
1 changed files with 27 additions and 15 deletions
  1. 27 15
      driver-icarus.c

+ 27 - 15
driver-icarus.c

@@ -163,13 +163,18 @@ static int icarus_gets(unsigned char *buf, size_t bufLen, int fd, volatile unsig
 		}
 
 		rc++;
-		if (*wr)
+		if (*wr) {
+			rc *= ICARUS_READ_FAULT_DECISECONDS;
+			applog(LOG_DEBUG,
+			       "Icarus Read: Work restart at %d.%d seconds", rc / 10, rc % 10);
 			return 1;
+		}
 		if (rc == ICARUS_READ_FAULT_COUNT) {
 			if (epollfd != -1)
 				close(epollfd);
+			rc *= ICARUS_READ_FAULT_DECISECONDS;
 			applog(LOG_DEBUG,
-			       "Icarus Read: No data in %d seconds", rc * ICARUS_READ_FAULT_DECISECONDS / 10);
+			       "Icarus Read: No data in %d.%d seconds", rc / 10, rc % 10);
 			return 1;
 		}
 	}
@@ -382,23 +387,22 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	}
 
 	// OK, done starting Icarus's next job... now process the last run's result!
-	nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
-	if (nonce_hex) {
-		applog(LOG_DEBUG, "Icarus %d returned (in %d.%06d seconds): %s",
-		       icarus->device_id, elapsed.tv_sec, elapsed.tv_usec, nonce_hex);
-		free(nonce_hex);
-	}
-
 	memcpy((char *)&nonce, nonce_bin, sizeof(nonce_bin));
 
+	// aborted before becoming idle, get new work
 	if (nonce == 0 && lret) {
 		memcpy(&state->last_work, work, sizeof(state->last_work));
+		uint32_t ESTIMATE_HASHES;
 		if (unlikely(elapsed.tv_sec > 12 || (elapsed.tv_sec == 11 && elapsed.tv_usec > 389666)))
-			return 0xffffffff;
-		// Approximately how much of the nonce Icarus scans in 1 second...
-		// 0x16a7a561 would be if it was exactly 380 MH/s
-		// 0x167a09b3 was the average over a 7500-sample period based on time to find actual shares
-		return (0x167a09b3 * elapsed.tv_sec) + (0x179 * elapsed.tv_usec);
+			ESTIMATE_HASHES = 0xffffffff;
+		else
+			// Approximately how much of the nonce Icarus scans in 1 second...
+			// 0x16a7a561 would be if it was exactly 380 MH/s
+			// 0x167a09b3 was the average over a 7500-sample period based on time to find actual shares
+			ESTIMATE_HASHES = (0x167a09b3 * elapsed.tv_sec) + (0x179 * elapsed.tv_usec);
+		applog(LOG_DEBUG, "Icarus %d no nonce = 0x%08x hashes (%ld.%06lds)",
+			icarus->device_id, ESTIMATE_HASHES, elapsed.tv_sec, elapsed.tv_usec);
+		return ESTIMATE_HASHES;
 	}
 
 #ifndef __BIG_ENDIAN__
@@ -407,6 +411,13 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	submit_nonce(thr, &state->last_work, nonce);
 	memcpy(&state->last_work, work, sizeof(state->last_work));
 
+	nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
+	if (nonce_hex) {
+		applog(LOG_DEBUG, "Icarus %d returned (elapsed %ld.%06ld seconds): %s",
+		       icarus->device_id, elapsed.tv_sec, elapsed.tv_usec, nonce_hex);
+		free(nonce_hex);
+	}
+
 	hash_count = (nonce & 0x7fffffff);
         if (hash_count == 0)
 		hash_count = 2;
@@ -417,7 +428,8 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
                         hash_count <<= 1;
         }
 
-	applog(LOG_DEBUG, "0x%x hashes in %d.%06d seconds", hash_count, elapsed.tv_sec, elapsed.tv_usec);
+	applog(LOG_DEBUG, "Icarus %d nonce = 0x%08x = 0x%08x hashes (%ld.%06lds)",
+			icarus->device_id, nonce, hash_count, elapsed.tv_sec, elapsed.tv_usec);
 
         return hash_count;
 }