15 int64_t nFirstBlockTime,
18 int64_t nActualTimespan = pindexPrev->
GetBlockTime() - nFirstBlockTime;
31 bnNew *= nActualTimespan;
34 if (bnNew > bnPowLimit) {
61 const uint32_t nProofOfWorkLimit =
70 return nProofOfWorkLimit;
75 while (pindex->
pprev &&
77 pindex->
nBits == nProofOfWorkLimit) {
78 pindex = pindex->
pprev;
85 uint32_t nBits = pindexPrev->
nBits;
86 if (nBits == nProofOfWorkLimit) {
87 return nProofOfWorkLimit;
96 if (mtp6blocks < 12 * 3600) {
110 if (nPow > bnPowLimit) {
129 largest_difficulty_target.
SetCompact(old_nbits);
130 largest_difficulty_target *= largest_timespan;
133 if (largest_difficulty_target > pow_limit) {
134 largest_difficulty_target = pow_limit;
141 if (maximum_new_target < new_target) {
147 smallest_difficulty_target.
SetCompact(old_nbits);
148 smallest_difficulty_target *= smallest_timespan;
151 if (smallest_difficulty_target > pow_limit) {
152 smallest_difficulty_target = pow_limit;
159 return new_target >= minimum_new_target;
arith_uint256 UintToArith256(const uint256 &a)
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
int64_t GetBlockTime() const
int64_t GetMedianTimePast() const
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
int nHeight
height of the entry in the chain. The genesis block has height 0
256-bit unsigned big integer.
arith_uint256 & SetCompact(uint32_t nCompact, bool *pfNegative=nullptr, bool *pfOverflow=nullptr)
The "compact" format is a representation of a whole number N using an unsigned 32bit number similar t...
uint32_t GetCompact(bool fNegative=false) const
uint32_t GetNextEDAWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params ¶ms)
Compute the next required proof of work using the legacy Bitcoin difficulty adjustment + Emergency Di...
bool PermittedEDADifficultyTransition(const Consensus::Params ¶ms, uint32_t old_nbits, arith_uint256 new_target)
Return false if the proof-of-work requirement specified by new_target is not possible,...
uint32_t CalculateNextWorkRequired(const CBlockIndex *pindexPrev, int64_t nFirstBlockTime, const Consensus::Params ¶ms)
Do difficulty adjustement Satoshi's way.
Parameters that influence chain consensus.
int64_t DifficultyAdjustmentInterval() const
int64_t nPowTargetTimespan
uint256 powLimit
Proof of work parameters.
int64_t nPowTargetSpacing
bool fPowAllowMinDifficultyBlocks