diff options
author | fireice-uk <fireice-uk@users.noreply.github.com> | 2017-10-13 16:35:10 +0100 |
---|---|---|
committer | fireice-uk <fireice-uk@users.noreply.github.com> | 2017-10-22 13:12:52 +0100 |
commit | f13f70c28eb9e4b38d3b4932f5845f1d5cc01906 (patch) | |
tree | dc2b85e4ddd9b02e35729502dd6ae96fc2443568 /xmrstak/backend/globalStates.hpp | |
parent | 610f4f0fa72c60daa14dc0661f58ba23563afb61 (diff) | |
download | xmr-stak-f13f70c28eb9e4b38d3b4932f5845f1d5cc01906.zip xmr-stak-f13f70c28eb9e4b38d3b4932f5845f1d5cc01906.tar.gz |
Implement pool-controlled nonce allocation
Diffstat (limited to 'xmrstak/backend/globalStates.hpp')
-rw-r--r-- | xmrstak/backend/globalStates.hpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/xmrstak/backend/globalStates.hpp b/xmrstak/backend/globalStates.hpp index 73ccf74..2be06ae 100644 --- a/xmrstak/backend/globalStates.hpp +++ b/xmrstak/backend/globalStates.hpp @@ -2,6 +2,7 @@ #include "miner_work.hpp" #include "xmrstak/misc/environment.hpp" +#include "xmrstak/misc/console.hpp" #include <atomic> @@ -9,9 +10,18 @@ namespace xmrstak { -struct globalStates +struct pool_data { + uint32_t iSavedNonce; + size_t pool_id; + + pool_data() : iSavedNonce(0), pool_id(0) + { + } +}; +struct globalStates +{ static inline globalStates& inst() { auto& env = environment::inst(); @@ -20,19 +30,26 @@ struct globalStates return *env.pglobalStates; } - void switch_work(miner_work& pWork); + //pool_data is in-out winapi style + void switch_work(miner_work& pWork, pool_data& dat); + + inline uint32_t calc_start_nonce(uint32_t nicehash_nonce, uint32_t reserve_count) + { + uint32_t debug_nonce = nicehash_nonce | iGlobalNonce.fetch_add(reserve_count); + printer::inst()->print_msg(L1, "DEBUG: start_nonce assigned nh: %.8x rc: %.8x nonce: %.8x", nicehash_nonce, reserve_count, debug_nonce); + } miner_work oGlobalWork; std::atomic<uint64_t> iGlobalJobNo; std::atomic<uint64_t> iConsumeCnt; + std::atomic<uint32_t> iGlobalNonce; uint64_t iThreadCount; + size_t pool_id; - private: - +private: globalStates() : iThreadCount(0) { } - }; } // namepsace xmrstak |