From 2d49a9a5d767b85981ce73f1832e0eae06d0d52f Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Thu, 17 Mar 2011 22:02:28 -0400 Subject: Introduce ability to interrupt hash scanners in the middle of scanning. --- sha256_4way.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sha256_4way.c') diff --git a/sha256_4way.c b/sha256_4way.c index 742682f..6d42451 100644 --- a/sha256_4way.c +++ b/sha256_4way.c @@ -100,7 +100,8 @@ static const unsigned int pSHA256InitState[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; -unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pdata, +unsigned int ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate, + unsigned char *pdata, unsigned char *phash1, unsigned char *phash, const unsigned char *ptarget, uint32_t max_nonce, unsigned long *nHashesDone) @@ -108,6 +109,8 @@ unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pd unsigned int *nNonce_p = (unsigned int*)(pdata + 12); unsigned int nonce = 0; + work_restart[thr_id].restart = 0; + for (;;) { unsigned int thash[9][NPAR] __attribute__((aligned(128))); @@ -135,7 +138,7 @@ unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pd } } - if (nonce >= max_nonce) + if ((nonce >= max_nonce) || work_restart[thr_id].restart) { *nHashesDone = nonce; return -1; -- cgit v1.2.3-18-g5258