13 pindex = pindex->
pprev;
19 std::vector<BlockHash>
have;
20 if (index ==
nullptr) {
34 if (
have.size() > 10) {
46 return ::GetLocator(
Tip());
50 if (pindex ==
nullptr) {
56 while (pindex && !
Contains(pindex)) {
57 pindex = pindex->
pprev;
63 std::pair<int64_t, int>
blockparams = std::make_pair(nTime, height);
64 std::vector<CBlockIndex *>::const_iterator
lower = std::lower_bound(
68 return pBlock->GetBlockTimeMax() < _blockparams.first ||
69 pBlock->nHeight < _blockparams.second;
95 if (
to.nChainWork >
from.nChainWork) {
96 r =
to.nChainWork -
from.nChainWork;
98 r =
from.nChainWork -
to.nChainWork;
103 return sign * std::numeric_limits<int64_t>::max();
114 if (
pa->nHeight >
pb->nHeight) {
116 }
else if (
pb->nHeight >
pa->nHeight) {
121 if (
pa->pskip &&
pb->pskip &&
pa->pskip !=
pb->pskip) {
137 if (
pa->nHeight >
pb->nHeight) {
138 pa =
pa->GetAncestor(
pb->nHeight);
139 }
else if (
pb->nHeight >
pa->nHeight) {
140 pb =
pb->GetAncestor(
pa->nHeight);
arith_uint256 GetBlockProof(const CBlockIndex &block)
std::vector< BlockHash > LocatorEntries(const CBlockIndex *index)
Construct a list of hash entries to put in a locator.
CBlockLocator GetLocator(const CBlockIndex *index)
Get a locator for 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...
const CBlockIndex * LastCommonAncestor(const CBlockIndex *pa, const CBlockIndex *pb)
Find the last common ancestor two blocks have.
bool AreOnTheSameFork(const CBlockIndex *pa, const CBlockIndex *pb)
Check if two block index are on the same fork.
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
CBlockIndex * pskip
pointer to the index of some further predecessor of this block
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
BlockHash GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
void SetTip(CBlockIndex &block)
Set/initialize a chain with a given tip.
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...
int Height() const
Return the maximal height in the chain.
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Find the last common block between this chain and a block index entry.
std::vector< CBlockIndex * > vChain
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
CBlockLocator GetLocator() const
Return a CBlockLocator that refers to the tip of this chain.
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...
uint64_t GetLow64() const
unsigned int bits() const
Returns the position of the highest bit set plus one, or zero if the value is zero.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Parameters that influence chain consensus.
int64_t nPowTargetSpacing