14 if (pindex ==
nullptr) {
21 pindex = pindex->
pprev;
27 std::vector<uint256> vHave;
41 pindex = (*this)[nHeight];
46 if (vHave.size() > 10)
54 if (pindex ==
nullptr) {
60 pindex = pindex->
pprev;
66 std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(
vChain.begin(),
vChain.end(), nTime,
67 [](
CBlockIndex* pBlock,
const int64_t& time) ->
bool {
return pBlock->GetBlockTimeMax() < time; });
68 return (lower ==
vChain.end() ?
nullptr : *lower);
72 int static inline InvertLowestOne(
int n) {
return n & (n - 1); }
75 int static inline GetSkipHeight(
int height) {
82 return (height & 1) ? InvertLowestOne(InvertLowestOne(height - 1)) + 1 : InvertLowestOne(height);
87 if (height > nHeight || height < 0)
91 int heightWalk = nHeight;
92 while (heightWalk > height) {
93 int heightSkip = GetSkipHeight(heightWalk);
94 int heightSkipPrev = GetSkipHeight(heightWalk - 1);
95 if (pindexWalk->
pskip !=
nullptr &&
96 (heightSkip == height ||
97 (heightSkip > height && !(heightSkipPrev < heightSkip - 2 &&
98 heightSkipPrev >= height)))) {
100 pindexWalk = pindexWalk->
pskip;
101 heightWalk = heightSkip;
104 pindexWalk = pindexWalk->
pprev;
113 return const_cast<CBlockIndex*
>(
this)->GetAncestor(height);
119 pskip = pprev->GetAncestor(GetSkipHeight(nHeight));
130 if ( nHeight == 0 ) {
159 if (fNegative || fOverflow || bnTarget == 0)
165 return (~bnTarget / (bnTarget + 1)) + 1;
195 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 ...
unsigned int bits() const
Returns the position of the highest bit set plus one, or zero if the value is zero.
CBlockIndex * pskip
pointer to the index of some further predecessor of this block
std::vector< CBlockIndex * > vChain
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
static const std::string REGTEST
const CBlockIndex * LastCommonAncestor(const CBlockIndex *pa, const CBlockIndex *pb)
Find the last common ancestor two blocks have.
static const std::string UNITTEST
const Consensus::Params & GetConsensus() const
assert(len-trim+(2 *lenIndices)<=WIDTH)
bool IsSupportContract() const
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
uint32_t ContractHeight
Block height at which Fabcoin Smart Contract hard fork becomes active.
void BuildSkip()
Build the skiplist pointer for this entry.
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Find the last common block between this chain and a block index entry.
Parameters that influence chain consensus.
256-bit unsigned big integer.
CBlockIndex * FindEarliestAtLeast(int64_t nTime) const
Find the earliest block with timestamp equal or greater than the given.
Signature sign(Secret const &_k, h256 const &_hash)
Returns siganture of message hash.
bool IsLegacyFormat() const
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...
const CChainParams & Params()
Return the currently selected parameters.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
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...
arith_uint256 GetBlockProof(const CBlockIndex &block)
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)
CBlockLocator GetLocator(const CBlockIndex *pindex=nullptr) const
Return a CBlockLocator that refers to a block in this chain (by default the tip). ...
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.
uint64_t GetLow64() const
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...
uint256 GetBlockHash() const