From efe69385f7d62da0defbf1626d7d1f690f8b58ad Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Sat, 3 Oct 2015 09:23:23 -0700 Subject: [PATCH] ScanMidstateForward: Set thread priority to THREAD_PRIORITY_LOWEST --- src/kernel.cpp | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/kernel.cpp b/src/kernel.cpp index 7d8a66a..2b4e5e6 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -458,6 +458,8 @@ public: void Do() { + SetThreadPriority(THREAD_PRIORITY_LOWEST); + CBigNum bnTargetPerCoinDay; bnTargetPerCoinDay.SetCompact(nBits); @@ -498,7 +500,7 @@ public: } } - vector > GetSolutions() + vector >& GetSolutions() { return workerSolutions; } @@ -520,20 +522,17 @@ bool ScanMidstateForward(SHA256_CTX &ctx, uint32_t nBits, uint32_t nInputTxTime, // TODO: custom threads amount uint32_t nThreads = boost::thread::hardware_concurrency(); - - uint32_t nBegin = SearchInterval.first; - uint32_t nEnd = SearchInterval.second; - uint32_t nPart = (nEnd - nBegin) / nThreads; + uint32_t nPart = (SearchInterval.second - SearchInterval.first) / nThreads; ScanMidstateWorker *workers = new ScanMidstateWorker[nThreads]; boost::thread_group group; for(size_t i = 0; i < nThreads; i++) { - uint32_t nIntervalBegin = nBegin + nPart * i; - uint32_t nIntervalEnd = nBegin + nPart * (i + 1); + uint32_t nBegin = SearchInterval.first + nPart * i; + uint32_t nEnd = SearchInterval.first + nPart * (i + 1); - workers[i] = ScanMidstateWorker(ctx, nBits, nInputTxTime, nValueIn, nIntervalBegin, nIntervalEnd); + workers[i] = ScanMidstateWorker(ctx, nBits, nInputTxTime, nValueIn, nBegin, nEnd); boost::function workerFnc = boost::bind(&ScanMidstateWorker::Do, &workers[i]); group.create_thread(workerFnc); -- 1.7.1