aboutsummaryrefslogtreecommitdiff
path: root/sha256_generic.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2011-03-17 22:02:28 -0400
committerJeff Garzik <jgarzik@pobox.com>2011-03-17 22:02:28 -0400
commit2d49a9a5d767b85981ce73f1832e0eae06d0d52f (patch)
tree2281b3960552a6fcb14a62f60bbe09b0fafa5227 /sha256_generic.c
parent4be41af2be1b2442161a98b9d7fbf2a61cc854f9 (diff)
Introduce ability to interrupt hash scanners in the middle of scanning.
Diffstat (limited to 'sha256_generic.c')
-rw-r--r--sha256_generic.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sha256_generic.c b/sha256_generic.c
index 596a6db..b30b326 100644
--- a/sha256_generic.c
+++ b/sha256_generic.c
@@ -237,7 +237,7 @@ const uint32_t sha256_init_state[8] = {
};
/* suspiciously similar to ScanHash* from bitcoin */
-bool scanhash_c(const unsigned char *midstate, unsigned char *data,
+bool scanhash_c(int thr_id, 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)
@@ -247,6 +247,8 @@ bool scanhash_c(const unsigned char *midstate, unsigned char *data,
uint32_t n = 0;
unsigned long stat_ctr = 0;
+ work_restart[thr_id].restart = 0;
+
while (1) {
n++;
*nonce = n;
@@ -261,7 +263,7 @@ bool scanhash_c(const unsigned char *midstate, unsigned char *data,
return true;
}
- if (n >= max_nonce) {
+ if ((n >= max_nonce) || work_restart[thr_id].restart) {
*hashes_done = stat_ctr;
return false;
}