Explicitly check the min-difficulty flag against boost::none
It isn't clear how a boost::optional that holds 0 (which is the case for regtest) is coerced to a boolean, unless you pore over the Boost documentation. An explicit check is clearer.
This commit is contained in:
@@ -103,7 +103,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
|||||||
pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||||
|
|
||||||
// Updating time can change work required on testnet:
|
// Updating time can change work required on testnet:
|
||||||
if (consensusParams.nPowAllowMinDifficultyBlocksAfterHeight) {
|
if (consensusParams.nPowAllowMinDifficultyBlocksAfterHeight != boost::none) {
|
||||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
|
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -727,7 +727,7 @@ void static BitcoinMiner()
|
|||||||
// Update nNonce and nTime
|
// Update nNonce and nTime
|
||||||
pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1);
|
pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1);
|
||||||
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
||||||
if (chainparams.GetConsensus().nPowAllowMinDifficultyBlocksAfterHeight)
|
if (chainparams.GetConsensus().nPowAllowMinDifficultyBlocksAfterHeight != boost::none)
|
||||||
{
|
{
|
||||||
// Changing pblock->nTime can change work required on testnet:
|
// Changing pblock->nTime can change work required on testnet:
|
||||||
hashTarget.SetCompact(pblock->nBits);
|
hashTarget.SetCompact(pblock->nBits);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||||||
{
|
{
|
||||||
// Comparing to pindexLast->nHeight with >= because this function
|
// Comparing to pindexLast->nHeight with >= because this function
|
||||||
// returns the work required for the block after pindexLast.
|
// returns the work required for the block after pindexLast.
|
||||||
if (params.nPowAllowMinDifficultyBlocksAfterHeight &&
|
if (params.nPowAllowMinDifficultyBlocksAfterHeight != boost::none &&
|
||||||
pindexLast->nHeight >= params.nPowAllowMinDifficultyBlocksAfterHeight.get())
|
pindexLast->nHeight >= params.nPowAllowMinDifficultyBlocksAfterHeight.get())
|
||||||
{
|
{
|
||||||
// Special difficulty rule for testnet:
|
// Special difficulty rule for testnet:
|
||||||
|
|||||||
Reference in New Issue
Block a user