#include "kernel_worker.h"
#include "txdb.h"
-extern uint32_t nStakeMaxAge;
extern uint32_t nStakeTargetSpacing;
using namespace std;
+uint32_t nStakeMinAge = 30 * nOneDay; // 30 days as zero time weight
+uint32_t nStakeMaxAge = 90 * nOneDay; // 90 days as full weight
+
// Protocol switch time for fixed kernel modifier interval
uint32_t nModifierSwitchTime = 1413763200; // Mon, 20 Oct 2014 00:00:00 GMT
uint32_t nModifierTestSwitchTime = 1397520000; // Tue, 15 Apr 2014 00:00:00 GMT
// 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))
return true;
}
-bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier)
+bool GetKernelStakeModifier(const uint256 &hashBlockFrom, uint64_t& nStakeModifier)
{
int nStakeModifierHeight;
int64_t nStakeModifierTime;
{
using namespace boost;
- auto nThreads = std::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;
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