30 int64_t nActualTimespan =
31 int64_t(pindexLast->
nTime) - int64_t(pindexFirst->
nTime);
38 work /= nActualTimespan;
45 return (-work) / work;
62 blocks[1] = pindex->
pprev;
63 blocks[0] = blocks[1]->
pprev;
66 if (blocks[0]->nTime > blocks[2]->nTime) {
67 std::swap(blocks[0], blocks[2]);
70 if (blocks[0]->nTime > blocks[1]->nTime) {
71 std::swap(blocks[0], blocks[1]);
74 if (blocks[1]->nTime > blocks[2]->nTime) {
75 std::swap(blocks[1], blocks[2]);
115 uint32_t nHeightFirst =
nHeight - 144;
125 if (nextTarget > powLimit) {
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
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
int64_t GetBlockTime() 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.
uint32_t GetCompact(bool fNegative=false) const
static arith_uint256 ComputeTarget(const CBlockIndex *pindexFirst, const CBlockIndex *pindexLast, const Consensus::Params ¶ms)
Compute a target based on the work done between 2 blocks and the time required to produce that work.
uint32_t GetNextDAAWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params ¶ms)
Compute the next required proof of work using a weighted average of the estimated hashrate per block.
static const CBlockIndex * GetSuitableBlock(const CBlockIndex *pindex)
To reduce the impact of timestamp manipulation, we select the block we are basing our computation on ...
Parameters that influence chain consensus.
int64_t DifficultyAdjustmentInterval() const
uint256 powLimit
Proof of work parameters.
int64_t nPowTargetSpacing
bool fPowAllowMinDifficultyBlocks