12 if (pindex ==
nullptr) {
20 pindex = pindex->
pprev;
26 std::vector<BlockHash> vHave;
47 if (vHave.size() > 10) {
56 if (pindex ==
nullptr) {
62 while (pindex && !
Contains(pindex)) {
63 pindex = pindex->
pprev;
69 std::pair<int64_t, int> blockparams = std::make_pair(nTime, height);
70 std::vector<CBlockIndex *>::const_iterator lower = std::lower_bound(
73 const std::pair<int64_t, int> &_blockparams) ->
bool {
74 return pBlock->GetBlockTimeMax() < _blockparams.first ||
75 pBlock->nHeight < _blockparams.second;
77 return (lower ==
vChain.end() ? nullptr : *lower);
85 if (fNegative || fOverflow || bnTarget == 0) {
92 return (~bnTarget / (bnTarget + 1)) + 1;
109 return sign * std::numeric_limits<int64_t>::max();
126 while (pa != pb && pa && pb) {
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
CBlockIndex * pskip
pointer to the index of some further predecessor of this block
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
const CBlockIndex * LastCommonAncestor(const CBlockIndex *pa, const CBlockIndex *pb)
Find the last common ancestor two blocks have.
int Height() const
Return the maximal height in the chain.
std::vector< CBlockIndex * > vChain
BlockHash GetBlockHash() const
CBlockIndex * FindEarliestAtLeast(int64_t nTime, int height) const
Find the earliest block with timestamp equal or greater than the given time and height equal or great...
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
int64_t nPowTargetSpacing
Parameters that influence chain consensus.
256-bit unsigned big integer.
void SetTip(CBlockIndex *pindex)
Set/initialize a chain with a given tip.
The block chain is a tree shaped structure starting with the genesis block at the root...
uint64_t GetLow64() const
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
CBlockLocator GetLocator(const CBlockIndex *pindex=nullptr) const
Return a CBlockLocator that refers to a block in this chain (by default the tip). ...
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...
bool AreOnTheSameFork(const CBlockIndex *pa, const CBlockIndex *pb)
Check if two block index are on the same fork.
arith_uint256 GetBlockProof(const CBlockIndex &block)
int nHeight
height of the entry in the chain. The genesis block has height 0
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Find the last common block between this chain and a block index entry.
int64_t GetBlockProofEquivalentTime(const CBlockIndex &to, const CBlockIndex &from, const CBlockIndex &tip, const Consensus::Params ¶ms)
Return the time it would take to redo the work difference between from and to, assuming the current h...
unsigned int bits() const
Returns the position of the highest bit set plus one, or zero if the value is zero.