aboutsummaryrefslogtreecommitdiff
path: root/sha256_cryptopp.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_cryptopp.c
parent4be41af2be1b2442161a98b9d7fbf2a61cc854f9 (diff)
Introduce ability to interrupt hash scanners in the middle of scanning.
Diffstat (limited to 'sha256_cryptopp.c')
-rw-r--r--sha256_cryptopp.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sha256_cryptopp.c b/sha256_cryptopp.c
index f5f8900..76e178c 100644
--- a/sha256_cryptopp.c
+++ b/sha256_cryptopp.c
@@ -91,7 +91,8 @@ 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,
+bool scanhash_cryptopp(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)
@@ -101,6 +102,8 @@ bool scanhash_cryptopp(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;
@@ -115,7 +118,7 @@ bool scanhash_cryptopp(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;
}
@@ -573,7 +576,8 @@ 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,
+bool scanhash_asm32(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)
@@ -583,6 +587,8 @@ bool scanhash_asm32(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;
@@ -599,7 +605,7 @@ bool scanhash_asm32(const unsigned char *midstate, unsigned char *data,
return true;
}
- if (n >= max_nonce) {
+ if ((n >= max_nonce) || work_restart[thr_id].restart) {
if (opt_debug)
fprintf(stderr, "DBG: end of nonce range\n");
*hashes_done = stat_ctr;