Browse Source

Merge branch 'bugfix_mm_nonce' into bfgminer

Luke Dashjr 13 years ago
parent
commit
4ae2442831
3 changed files with 9 additions and 6 deletions
  1. 1 1
      driver-modminer.c
  2. 7 4
      miner.c
  3. 1 1
      miner.h

+ 1 - 1
driver-modminer.c

@@ -492,7 +492,7 @@ modminer_process_results(struct thr_info*thr)
 		mutex_unlock(&modminer->device_mutex);
 		mutex_unlock(&modminer->device_mutex);
 		if (memcmp(&nonce, "\xff\xff\xff\xff", 4)) {
 		if (memcmp(&nonce, "\xff\xff\xff\xff", 4)) {
 			state->no_nonce_counter = 0;
 			state->no_nonce_counter = 0;
-			bad = !test_nonce(work, nonce);
+			bad = !test_nonce(work, nonce, false);
 			if (!bad)
 			if (!bad)
 			{
 			{
 				++state->good_share_counter;
 				++state->good_share_counter;

+ 7 - 4
miner.c

@@ -4179,7 +4179,7 @@ err_out:
 	return false;
 	return false;
 }
 }
 
 
-bool hashtest(const struct work *work)
+bool hashtest(const struct work *work, bool checktarget)
 {
 {
 	uint32_t *data32 = (uint32_t *)(work->data);
 	uint32_t *data32 = (uint32_t *)(work->data);
 	unsigned char swap[128];
 	unsigned char swap[128];
@@ -4195,6 +4195,9 @@ bool hashtest(const struct work *work)
 	sha2(swap, 80, hash1, false);
 	sha2(swap, 80, hash1, false);
 	sha2(hash1, 32, hash2, false);
 	sha2(hash1, 32, hash2, false);
 
 
+	if (!checktarget)
+		return hash2_32[7] == 0;
+
 	for (i = 0; i < 32 / 4; i++)
 	for (i = 0; i < 32 / 4; i++)
 		hash2_32[i] = swab32(hash2_32[i]);
 		hash2_32[i] = swab32(hash2_32[i]);
 
 
@@ -4204,21 +4207,21 @@ bool hashtest(const struct work *work)
 
 
 }
 }
 
 
-bool test_nonce(struct work *work, uint32_t nonce)
+bool test_nonce(struct work *work, uint32_t nonce, bool checktarget)
 {
 {
 	work->data[64 + 12 + 0] = (nonce >> 0) & 0xff;
 	work->data[64 + 12 + 0] = (nonce >> 0) & 0xff;
 	work->data[64 + 12 + 1] = (nonce >> 8) & 0xff;
 	work->data[64 + 12 + 1] = (nonce >> 8) & 0xff;
 	work->data[64 + 12 + 2] = (nonce >> 16) & 0xff;
 	work->data[64 + 12 + 2] = (nonce >> 16) & 0xff;
 	work->data[64 + 12 + 3] = (nonce >> 24) & 0xff;
 	work->data[64 + 12 + 3] = (nonce >> 24) & 0xff;
 
 
-	return hashtest(work);
+	return hashtest(work, checktarget);
 }
 }
 
 
 bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 {
 {
 	/* Do one last check before attempting to submit the work */
 	/* Do one last check before attempting to submit the work */
 	/* Side effect: sets work->data for us */
 	/* Side effect: sets work->data for us */
-	if (!test_nonce(work, nonce)) {
+	if (!test_nonce(work, nonce, true)) {
 		applog(LOG_INFO, "Share below target");
 		applog(LOG_INFO, "Share below target");
 		return true;
 		return true;
 	}
 	}

+ 1 - 1
miner.h

@@ -776,7 +776,7 @@ struct work {
 };
 };
 
 
 extern void get_datestamp(char *, struct timeval *);
 extern void get_datestamp(char *, struct timeval *);
-extern bool test_nonce(struct work *work, uint32_t nonce);
+extern bool test_nonce(struct work *work, uint32_t nonce, bool checktarget);
 bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
 bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
 extern void tailsprintf(char *f, const char *fmt, ...);
 extern void tailsprintf(char *f, const char *fmt, ...);
 extern void wlogprint(const char *f, ...);
 extern void wlogprint(const char *f, ...);