Browse Source

Merge commit 'b5ae1a9' into bfgminer-3.5.x

Luke Dashjr 12 years ago
parent
commit
42e9dbc028
2 changed files with 10 additions and 10 deletions
  1. 1 3
      driver-cpu.c
  2. 9 7
      scrypt.c

+ 1 - 3
driver-cpu.c

@@ -135,9 +135,7 @@ extern bool scanhash_sse2_32(struct thr_info*, const unsigned char *pmidstate, u
 	uint32_t max_nonce, uint32_t *last_nonce,
 	uint32_t max_nonce, uint32_t *last_nonce,
 	uint32_t nonce);
 	uint32_t nonce);
 
 
-extern bool scanhash_scrypt(struct thr_info *thr, int thr_id, unsigned char *pdata, unsigned char *scratchbuf,
-	const unsigned char *ptarget,
-	uint32_t max_nonce, unsigned long *hashes_done);
+extern bool scanhash_scrypt(struct thr_info *, const unsigned char *pmidstate, unsigned char *pdata, unsigned char *phash1, unsigned char __maybe_unused *phash, const unsigned char *ptarget, uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
 
 
 
 
 
 

+ 9 - 7
scrypt.c

@@ -465,28 +465,30 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *p
 		applog(LOG_ERR, "Failed to malloc scratchbuf in scanhash_scrypt");
 		applog(LOG_ERR, "Failed to malloc scratchbuf in scanhash_scrypt");
 		return ret;
 		return ret;
 	}
 	}
-
+	
 	while(1) {
 	while(1) {
 		uint32_t ostate[8];
 		uint32_t ostate[8];
 
 
-		*nonce = ++n;
-		data[19] = htobe32(n);
+		data[19] = n;
 		scrypt_1024_1_1_256_sp(data, scratchbuf, ostate);
 		scrypt_1024_1_1_256_sp(data, scratchbuf, ostate);
 		tmp_hash7 = be32toh(ostate[7]);
 		tmp_hash7 = be32toh(ostate[7]);
 
 
 		if (unlikely(tmp_hash7 <= Htarg)) {
 		if (unlikely(tmp_hash7 <= Htarg)) {
-			((uint32_t *)pdata)[19] = htobe32(n);
-			*last_nonce = n;
+			// nonce passed in data is always little-endian, while we are always hashing in big endian
+			*nonce = swab32(n);
 			ret = true;
 			ret = true;
 			break;
 			break;
 		}
 		}
 
 
 		if (unlikely((n >= max_nonce) || thr->work_restart)) {
 		if (unlikely((n >= max_nonce) || thr->work_restart)) {
-			*last_nonce = n;
 			break;
 			break;
 		}
 		}
+		
+		++n;
 	}
 	}
 
 
-	free(scratchbuf);;
+	*last_nonce = n;
+	
+	free(scratchbuf);
 	return ret;
 	return ret;
 }
 }