diff options
author | fireice-uk <fireice-uk@users.noreply.github.com> | 2017-10-23 19:14:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 19:14:20 +0100 |
commit | 7030f1b3ab2ff9670c5251919d00387095cf71f2 (patch) | |
tree | 40c19dd7735f372aa194f1399aed4a30d81a1c24 /xmrstak/backend/globalStates.hpp | |
parent | a7116b999efae0b303cd2474bbea3c918a4fe8b3 (diff) | |
parent | 14ceeaca2ea501d1c4ad9ba90655cc3204cd27c3 (diff) | |
download | xmr-stak-7030f1b3ab2ff9670c5251919d00387095cf71f2.zip xmr-stak-7030f1b3ab2ff9670c5251919d00387095cf71f2.tar.gz |
Merge pull request #45 from fireice-uk/topic-nonce-alloc
Implement pool-controlled nonce allocation
Diffstat (limited to 'xmrstak/backend/globalStates.hpp')
-rw-r--r-- | xmrstak/backend/globalStates.hpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/xmrstak/backend/globalStates.hpp b/xmrstak/backend/globalStates.hpp index 73ccf74..1c28d5c 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,28 @@ 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 void calc_start_nonce(uint32_t& nonce, bool use_nicehash, uint32_t reserve_count) + { + if(use_nicehash) + nonce = (nonce & 0xFF000000) | iGlobalNonce.fetch_add(reserve_count); + else + nonce = iGlobalNonce.fetch_add(reserve_count); + } 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 |