diff --git a/src/pow.cpp b/src/pow.cpp --- a/src/pow.cpp +++ b/src/pow.cpp @@ -14,7 +14,7 @@ /** * Compute the next required proof of work using the legacy Bitcoin difficulty - * adjustement + Emergency Difficulty Adjustement (EDA). + * adjustment + Emergency Difficulty Adjustment (EDA). */ static uint32_t GetNextEDAWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, @@ -55,13 +55,13 @@ return pindex->nBits; } - // We can't go bellow the minimum, so early bail. + // We can't go below the minimum, so bail early. uint32_t nBits = pindexPrev->nBits; if (nBits == nProofOfWorkLimit) { return nProofOfWorkLimit; } - // If producing the last 6 block took less than 12h, we keep the same + // If producing the last 6 blocks took less than 12h, we keep the same // difficulty. const CBlockIndex *pindex6 = pindexPrev->GetAncestor(nHeight - 7); assert(pindex6); @@ -71,14 +71,16 @@ return nBits; } - // If producing the last 6 block took more than 12h, increase the difficulty - // target by 1/4 (which reduces the difficulty by 20%). This ensure the - // chain do not get stuck in case we lose hashrate abruptly. + // If producing the last 6 blocks took more than 12h, increase the + // difficulty + // target by 1/4 (which reduces the difficulty by 20%). This + // ensures that the chain do not get stuck in case we lose + // hashrate abruptly. arith_uint256 nPow; nPow.SetCompact(nBits); nPow += (nPow >> 2); - // Make sure we do not go bellow allowed values. + // Make sure we do not go below allowed values. const arith_uint256 bnPowLimit = UintToArith256(params.powLimit); if (nPow > bnPowLimit) nPow = bnPowLimit; @@ -158,7 +160,7 @@ } /** - * Compute the a target based on the work done between 2 blocks and the time + * Compute a target based on the work done between 2 blocks and the time * required to produce that work. */ static arith_uint256 ComputeTarget(const CBlockIndex *pindexFirst, @@ -175,8 +177,7 @@ work *= params.nPowTargetSpacing; // In order to avoid difficulty cliffs, we bound the amplitude of the - // adjustement we are going to do. - assert(pindexLast->nTime > pindexFirst->nTime); + // adjustment we are going to do to a factor in [0.5, 2]. int64_t nActualTimespan = pindexLast->nTime - pindexFirst->nTime; if (nActualTimespan > 288 * params.nPowTargetSpacing) { nActualTimespan = 288 * params.nPowTargetSpacing; @@ -202,7 +203,7 @@ assert(pindex->nHeight >= 3); /** - * In order to avoid a block is a very skewed timestamp to have too much + * In order to avoid a block with a very skewed timestamp having too much * influence, we select the median of the 3 top most blocks as a starting * point. */ @@ -252,7 +253,7 @@ return UintToArith256(params.powLimit).GetCompact(); } - // Compute the difficulty based on the full adjustement interval. + // Compute the difficulty based on the full adjustment interval. const uint32_t nHeight = pindexPrev->nHeight; assert(nHeight >= params.DifficultyAdjustmentInterval());