Use MoneyRange(txout.nValue) to get rid of excessive checking.
[novacoin.git] / src / kernel.cpp
index 4d81ea5..422c48e 100644 (file)
@@ -301,7 +301,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64_t& nStake
 
 // The stake modifier used to hash for a stake kernel is chosen as the stake
 // modifier about a selection interval later than the coin generating the kernel
-static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
+static bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
 {
     nStakeModifier = 0;
     if (!mapBlockIndex.count(hashBlockFrom))
@@ -333,7 +333,7 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifi
     return true;
 }
 
-bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier)
+bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier)
 {
     int nStakeModifierHeight;
     int64_t nStakeModifierTime;
@@ -429,7 +429,11 @@ bool ScanKernelForward(unsigned char *kernel, uint32_t nBits, uint32_t nInputTxT
     {
         using namespace boost;
 
-        auto nThreads = thread::hardware_concurrency();
+        auto nThreads = boost::thread::hardware_concurrency();
+        if (nThreads == 0) {
+           nThreads = 1;
+           printf("Warning: hardware_concurrency() failed in %s:%d\n", __FILE__, __LINE__);
+        }
         auto vWorkers = vector<KernelWorker>(nThreads);
         auto nPart = (SearchInterval.second - SearchInterval.first) / nThreads;
         thread_group group;
@@ -504,7 +508,7 @@ uint32_t GetStakeModifierChecksum(const CBlockIndex* pindex)
     ss << pindex->nFlags << pindex->hashProofOfStake << pindex->nStakeModifier;
     auto hashChecksum = Hash(ss.begin(), ss.end());
     hashChecksum >>= (256 - 32);
-    return static_cast<uint32_t>(hashChecksum.Get64());
+    return hashChecksum.Get32();
 }
 
 // Check stake modifier hard checkpoints