|
@@ -465,27 +465,33 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *p
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // we always hash in big endian
|
|
|
|
|
+ n = htobe32(n);
|
|
|
|
|
+
|
|
|
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 is expected to be host-endian
|
|
|
|
|
+ *last_nonce = be32toh(n);
|
|
|
|
|
+
|
|
|
|
|
+ free(scratchbuf);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|