diff options
author | psychocrypt <psychocryptHPC@gmail.com> | 2018-05-22 23:05:46 +0200 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2018-06-04 21:07:11 +0000 |
commit | 34098ee5546d34068ae16963b9e875fd78e215f9 (patch) | |
tree | 83a6c348a40838dc399373c1058024fb76d0f74d /xmrstak/backend/cpu/minethd.cpp | |
parent | 22732aa90e8eb1219691875b4019257535cff462 (diff) | |
download | xmr-stak-34098ee5546d34068ae16963b9e875fd78e215f9.zip xmr-stak-34098ee5546d34068ae16963b9e875fd78e215f9.tar.gz |
fix duplicated nonce usage
- avoid that a nonce which not fits to the current job is used (check jobId after start nonce is consumed)
- move jobId check into the if condition to get a new bunch of nonces
- CPU: add jobId validation after the start nonce is consumed
Diffstat (limited to 'xmrstak/backend/cpu/minethd.cpp')
-rw-r--r-- | xmrstak/backend/cpu/minethd.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index 3dc1063..aeab516 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -499,6 +499,9 @@ void minethd::work_main() if((nonce_ctr++ & (nonce_chunk-1)) == 0) { globalStates::inst().calc_start_nonce(result.iNonce, oWork.bNiceHash, nonce_chunk); + // check if the job is still valid, there is a small posibility that the job is switched + if(globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) != iJobNo) + break; } *piNonce = result.iNonce; @@ -806,6 +809,9 @@ void minethd::multiway_work_main() { globalStates::inst().calc_start_nonce(iNonce, oWork.bNiceHash, nonce_chunk); nonce_ctr = nonce_chunk; + // check if the job is still valid, there is a small posibility that the job is switched + if(globalStates::inst().iGlobalJobNo.load(std::memory_order_relaxed) != iJobNo) + break; } for (size_t i = 0; i < N; i++) |