diff options
author | jtimon <jtimon@monetize.io> | 2014-03-22 20:09:12 +0100 |
---|---|---|
committer | jtimon <jtimon@monetize.io> | 2014-06-04 13:29:36 +0200 |
commit | 21913a9ac9525547ebe18619748abb18a2ca8cdf (patch) | |
tree | 77db605e657068ef04108c828a4da38bdc18fd34 /src | |
parent | d754f34e8d470d5d89e2bc31ff1ab60ae5889266 (diff) |
Add AllowMinDifficultyBlocks chain parameter
Diffstat (limited to 'src')
-rw-r--r-- | src/chainparams.cpp | 2 | ||||
-rw-r--r-- | src/chainparams.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 6 | ||||
-rw-r--r-- | src/miner.cpp | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 86d80629eb..c43de2e72d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -224,6 +224,8 @@ public: base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF); base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94); } + + virtual bool AllowMinDifficultyBlocks() const { return true; } virtual Network NetworkID() const { return CChainParams::TESTNET; } }; static CTestNetParams testNetParams; diff --git a/src/chainparams.h b/src/chainparams.h index f400907d73..e1ce86550c 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -70,6 +70,8 @@ public: virtual bool MiningRequiresPeers() const { return true; } /* Default value for -checkmempool argument */ virtual bool DefaultCheckMemPool() const { return false; } + /* Allow mining of a min-difficulty block */ + virtual bool AllowMinDifficultyBlocks() const { return false; } const string& DataDir() const { return strDataDir; } /* Make miner stop after a block is found. In RPC, don't return * until nGenProcLimit blocks are generated */ diff --git a/src/main.cpp b/src/main.cpp index e6519864d8..7d0a57657b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1210,7 +1210,7 @@ unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime) const uint256 &bnLimit = Params().ProofOfWorkLimit(); // Testnet has min-difficulty blocks // after nTargetSpacing*2 time between blocks: - if (TestNet() && nTime > nTargetSpacing*2) + if (Params().AllowMinDifficultyBlocks() && nTime > nTargetSpacing*2) return bnLimit.GetCompact(); uint256 bnResult; @@ -1238,7 +1238,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead // Only change once per interval if ((pindexLast->nHeight+1) % nInterval != 0) { - if (TestNet()) + if (Params().AllowMinDifficultyBlocks()) { // Special difficulty rule for testnet: // If the new block's timestamp is more than 2* 10 minutes @@ -1468,7 +1468,7 @@ void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev) block.nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); // Updating time can change work required on testnet: - if (TestNet()) + if (Params().AllowMinDifficultyBlocks()) block.nBits = GetNextWorkRequired(pindexPrev, &block); } diff --git a/src/miner.cpp b/src/miner.cpp index 44c2faaa4c..708b9248f3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -632,7 +632,7 @@ void static BitcoinMiner(CWallet *pwallet) // Update nTime every few seconds UpdateTime(*pblock, pindexPrev); nBlockTime = ByteReverse(pblock->nTime); - if (TestNet()) + if (Params().AllowMinDifficultyBlocks()) { // Changing pblock->nTime can change work required on testnet: nBlockBits = ByteReverse(pblock->nBits); |