diff options
author | Jeff Garzik <jeff@garzik.org> | 2011-02-03 00:46:55 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2011-02-03 00:46:55 -0500 |
commit | 714c0fd7c90cdb11742f7f2c91a65357a7bf5d5a (patch) | |
tree | f96729029d4411e1f6a5b2aa484bbf7008ba09dd /sha256_cryptopp.c | |
parent | c68ffb30dd17b32f69665af18b72687875770972 (diff) |
Continue scanhash, even if high 32 bits are zero.
Previously, we would stop the scan if the high 32 bits of the hash were zero,
as a quick shortcut for testing the full hash. If this quick test succeeded,
we would pass the work to the server for full validation.
Change this logic to perform full validation inside minerd, so that work may
be resumed more quickly if hash > target.
Diffstat (limited to 'sha256_cryptopp.c')
-rw-r--r-- | sha256_cryptopp.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sha256_cryptopp.c b/sha256_cryptopp.c index 4ada480..47d4921 100644 --- a/sha256_cryptopp.c +++ b/sha256_cryptopp.c @@ -93,6 +93,7 @@ static void runhash(void *state, const void *input, const void *init) /* suspiciously similar to ScanHash* from bitcoin */ bool scanhash_cryptopp(const unsigned char *midstate, unsigned char *data, unsigned char *hash1, unsigned char *hash, + const unsigned char *target, uint32_t max_nonce, unsigned long *hashes_done) { uint32_t *hash32 = (uint32_t *) hash; @@ -109,9 +110,7 @@ bool scanhash_cryptopp(const unsigned char *midstate, unsigned char *data, stat_ctr++; - if (hash32[7] == 0) { - print_pow(hash); - + if ((hash32[7] == 0) && fulltest(hash, target)) { *hashes_done = stat_ctr; return true; } @@ -578,6 +577,7 @@ static void runhash32(void *state, const void *input, const void *init) /* suspiciously similar to ScanHash* from bitcoin */ bool scanhash_asm32(const unsigned char *midstate, unsigned char *data, unsigned char *hash1, unsigned char *hash, + const unsigned char *target, uint32_t max_nonce, unsigned long *hashes_done) { uint32_t *hash32 = (uint32_t *) hash; @@ -594,8 +594,8 @@ bool scanhash_asm32(const unsigned char *midstate, unsigned char *data, stat_ctr++; - if (hash32[7] == 0) { - print_pow(hash); + if ((hash32[7] == 0) && fulltest(hash, target)) { + fulltest(hash, target); *hashes_done = stat_ctr; return true; |