Browse Source

Semi-Merge commit 'c1ff90a' into cg_merges_20130524b (only change symbol signatures)

Conflicts:
	findnonce.c
	miner.c
Luke Dashjr 12 years ago
parent
commit
3dc6ea620c
4 changed files with 15 additions and 13 deletions
  1. 3 5
      miner.c
  2. 3 3
      miner.h
  3. 6 2
      scrypt.c
  4. 3 3
      scrypt.h

+ 3 - 5
miner.c

@@ -6929,11 +6929,9 @@ enum test_nonce2_result _test_nonce2(struct work *work, uint32_t nonce, bool che
 	*work_nonce = htole32(nonce);
 	*work_nonce = htole32(nonce);
 
 
 #ifdef USE_SCRYPT
 #ifdef USE_SCRYPT
-	if (opt_scrypt) {
-		if (!scrypt_test(work->data, work->target, nonce))
-			return TNR_BAD;
-		return TNR_GOOD;
-	}
+	if (opt_scrypt)
+		// NOTE: Depends on scrypt_test return matching enum values
+		return scrypt_test(work->data, work->target, nonce);
 #endif
 #endif
 
 
 	return hashtest2(work, checktarget);
 	return hashtest2(work, checktarget);

+ 3 - 3
miner.h

@@ -1222,9 +1222,9 @@ struct work {
 extern void get_datestamp(char *, struct timeval *);
 extern void get_datestamp(char *, struct timeval *);
 extern void inc_hw_errors(struct thr_info *thr);
 extern void inc_hw_errors(struct thr_info *thr);
 enum test_nonce2_result {
 enum test_nonce2_result {
-	TNR_GOOD,
-	TNR_HIGH,
-	TNR_BAD,
+	TNR_GOOD = 1,
+	TNR_HIGH = 0,
+	TNR_BAD = -1,
 };
 };
 extern enum test_nonce2_result _test_nonce2(struct work *, uint32_t nonce, bool checktarget);
 extern enum test_nonce2_result _test_nonce2(struct work *, uint32_t nonce, bool checktarget);
 #define test_nonce(work, nonce, checktarget)  (_test_nonce2(work, nonce, checktarget) == TNR_GOOD)
 #define test_nonce(work, nonce, checktarget)  (_test_nonce2(work, nonce, checktarget) == TNR_GOOD)

+ 6 - 2
scrypt.c

@@ -420,7 +420,7 @@ void scrypt_regenhash(struct work *work)
 }
 }
 
 
 /* Used externally as confirmation of correct OCL code */
 /* Used externally as confirmation of correct OCL code */
-bool scrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce)
+int scrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce)
 {
 {
 	uint32_t tmp_hash7, Htarg = ((const uint32_t *)ptarget)[7];
 	uint32_t tmp_hash7, Htarg = ((const uint32_t *)ptarget)[7];
 	uint32_t data[20], ohash[8];
 	uint32_t data[20], ohash[8];
@@ -432,7 +432,11 @@ bool scrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t no
 	scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
 	scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
 	tmp_hash7 = be32toh(ohash[7]);
 	tmp_hash7 = be32toh(ohash[7]);
 
 
-	return (tmp_hash7 <= Htarg);
+	/* FIXME: Needs to be able to return 0 as well for not meeting target
+	 * but target diff currently is sent to devices. */
+	if (tmp_hash7 > Htarg)
+		return -1;
+	return 1;
 }
 }
 
 
 bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *pmidstate,
 bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *pmidstate,

+ 3 - 3
scrypt.h

@@ -4,16 +4,16 @@
 #include "miner.h"
 #include "miner.h"
 
 
 #ifdef USE_SCRYPT
 #ifdef USE_SCRYPT
-extern bool scrypt_test(unsigned char *pdata, const unsigned char *ptarget,
+extern int scrypt_test(unsigned char *pdata, const unsigned char *ptarget,
 			uint32_t nonce);
 			uint32_t nonce);
 extern void scrypt_regenhash(struct work *work);
 extern void scrypt_regenhash(struct work *work);
 
 
 #else /* USE_SCRYPT */
 #else /* USE_SCRYPT */
-static inline bool scrypt_test(__maybe_unused unsigned char *pdata,
+static inline int scrypt_test(__maybe_unused unsigned char *pdata,
 			       __maybe_unused const unsigned char *ptarget,
 			       __maybe_unused const unsigned char *ptarget,
 			       __maybe_unused uint32_t nonce)
 			       __maybe_unused uint32_t nonce)
 {
 {
-	return false;
+	return 0;
 }
 }
 
 
 static inline void scrypt_regenhash(__maybe_unused struct work *work)
 static inline void scrypt_regenhash(__maybe_unused struct work *work)