Browse Source

Bugfix: cpu: Increment nonce after checking (rather than before), to avoid skipping the first nonce of each scanhash call

Luke Dashjr 13 years ago
parent
commit
a632372171
4 changed files with 8 additions and 4 deletions
  1. 2 1
      sha256_4way.c
  2. 2 1
      sha256_cryptopp.c
  3. 2 1
      sha256_generic.c
  4. 2 1
      sha256_via.c

+ 2 - 1
sha256_4way.c

@@ -119,7 +119,6 @@ bool ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
         unsigned int thash[9][NPAR] __attribute__((aligned(128)));
         unsigned int thash[9][NPAR] __attribute__((aligned(128)));
 	int j;
 	int j;
 
 
-	nonce += NPAR;
 	*nNonce_p = nonce;
 	*nNonce_p = nonce;
 
 
         DoubleBlockSHA256(pdata, phash1, pmidstate, thash, pSHA256InitState);
         DoubleBlockSHA256(pdata, phash1, pmidstate, thash, pSHA256InitState);
@@ -147,6 +146,8 @@ bool ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
             *last_nonce = nonce;
             *last_nonce = nonce;
             return false;
             return false;
         }
         }
+
+		nonce += NPAR;
     }
     }
 }
 }
 
 

+ 2 - 1
sha256_cryptopp.c

@@ -108,7 +108,6 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
 	work_restart[thr_id].restart = 0;
 	work_restart[thr_id].restart = 0;
 
 
 	while (1) {
 	while (1) {
-		n++;
 		*nonce = n;
 		*nonce = n;
 
 
 		runhash(hash1, data, midstate);
 		runhash(hash1, data, midstate);
@@ -123,6 +122,8 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
 			*last_nonce = n;
 			*last_nonce = n;
 			return false;
 			return false;
 		}
 		}
+
+		n++;
 	}
 	}
 }
 }
 
 

+ 2 - 1
sha256_generic.c

@@ -254,7 +254,6 @@ bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data,
 	work_restart[thr_id].restart = 0;
 	work_restart[thr_id].restart = 0;
 
 
 	while (1) {
 	while (1) {
-		n++;
 		*nonce = n;
 		*nonce = n;
 
 
 		runhash(hash1, data, midstate);
 		runhash(hash1, data, midstate);
@@ -271,6 +270,8 @@ bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data,
 			*last_nonce = n;
 			*last_nonce = n;
 			return false;
 			return false;
 		}
 		}
+
+		n++;
 	}
 	}
 }
 }
 
 

+ 2 - 1
sha256_via.c

@@ -46,7 +46,6 @@ bool scanhash_via(int thr_id, const unsigned char *pmidstate,
 		data32[i] = swab32(((uint32_t *)data_inout)[i]);
 		data32[i] = swab32(((uint32_t *)data_inout)[i]);
 
 
 	while (1) {
 	while (1) {
-		n++;
 		*nonce = n;
 		*nonce = n;
 
 
 		/* first SHA256 transform */
 		/* first SHA256 transform */
@@ -80,6 +79,8 @@ bool scanhash_via(int thr_id, const unsigned char *pmidstate,
 			*last_nonce = n;
 			*last_nonce = n;
 			return false;
 			return false;
 		}
 		}
+
+		n++;
 	}
 	}
 }
 }