6 #ifndef BITCOIN_CHAIN_H 7 #define BITCOIN_CHAIN_H 53 template <
typename Stream,
typename Operation>
297 std::sort(pbegin, pend);
298 return pbegin[(pend - pbegin)/2];
303 return strprintf(
"CBlockIndex(pprev=%p, nHeight=%d, merkle=%s, hashBlock=%s)",
363 template <
typename Stream,
typename Operation>
365 int _nVersion = s.GetVersion();
403 std::string str =
"CDiskBlockIndex(";
405 str +=
strprintf(
"\n hashBlock=%s, hashPrev=%s)",
430 if (nHeight < 0 || nHeight >= (
int)
vChain.size())
443 return (*
this)[pindex->
nHeight] == pindex;
449 return (*
this)[pindex->
nHeight + 1];
472 #endif // BITCOIN_CHAIN_H arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
Definition: chain.h:164
void SerializationOp(Stream &s, Operation ser_action)
Definition: chain.h:364
int32_t nSequenceId
(memory only) Sequential id assigned to distinguish order in which blocks are received.
Definition: chain.h:186
Definition: flatfile.h:14
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn)
Definition: chain.h:81
uint64_t nTimeLast
latest time of block in file
Definition: chain.h:49
unsigned int nTimeMax
(memory only) Maximum nTime in the chain up to and including this block.
Definition: chain.h:189
descends from failed block
Definition: chain.h:128
void SetTip(CBlockIndex *pindex)
Definition: chain.cpp:11
uint64_t nTimeFirst
earliest time of block in file
Definition: chain.h:48
uint32_t nTime
Definition: chain.h:181
uint256 hashPrev
Definition: chain.h:351
const CBlockIndex * LastCommonAncestor(const CBlockIndex *pa, const CBlockIndex *pb)
Definition: chain.cpp:156
bool RaiseValidity(enum BlockStatus nUpTo)
Definition: chain.h:320
CBlockIndex * pskip
pointer to the index of some further predecessor of this block
Definition: chain.h:149
int32_t nVersion
block header
Definition: chain.h:179
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
Check whether this block index entry is valid up to the passed validity level.
Definition: chain.h:310
CBlockHeader GetBlockHeader() const
Definition: chain.h:248
unsigned int nHeight
Definition: mempool_eviction.cpp:15
uint32_t nNonce
Definition: chain.h:183
CDiskBlockIndex()
Definition: chain.h:353
unsigned int nUndoSize
number of used bytes in the undo file
Definition: chain.h:45
unsigned int nUndoPos
Byte offset within rev?????.dat where this block's undo data is stored.
Definition: chain.h:161
int64_t GetBlockTimeMax() const
Definition: chain.h:280
std::string ToString() const
Definition: validation.cpp:4599
stage after last reached validness failed
Definition: chain.h:127
undo data available in rev*.dat
Definition: chain.h:124
CBlockIndex(const CBlockHeader &block)
Definition: chain.h:219
unsigned int nTx
Definition: chain.h:168
Unused.
Definition: chain.h:96
uint32_t nBits
Definition: chain.h:182
std::string ToString() const
Definition: chain.h:301
static constexpr int64_t TIMESTAMP_WINDOW
Definition: chain.h:30
void SetNull()
Definition: chain.h:191
unsigned int nSize
number of used bytes of block file
Definition: chain.h:44
CBlockIndex * operator[](int nHeight) const
Definition: chain.h:429
bool Contains(const CBlockIndex *pindex) const
Definition: chain.h:442
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
Definition: chain.h:176
std::vector< CBlockIndex * > vChain
Definition: chain.h:415
FlatFilePos GetUndoPos() const
Definition: chain.h:239
arith_uint256 GetBlockProof(const CBlockIndex &block)
Definition: chain.cpp:122
const uint256 * phashBlock
pointer to the hash of the block, if any. Memory is owned by this CBlockIndex
Definition: chain.h:143
ADD_SERIALIZE_METHODS
Definition: chain.h:51
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
Definition: chain.h:117
Definition: serialize.h:177
unsigned int nHeightLast
highest height of block in file
Definition: chain.h:47
unsigned int uint32_t
Definition: stdint.h:21
uint256 hashMerkleRoot
Definition: chain.h:180
Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future.
Definition: chain.h:99
unsigned long long uint64_t
Definition: stdint.h:22
CDiskBlockIndex(const CBlockIndex *pindex)
Definition: chain.h:357
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Definition: chain.cpp:51
CBlockIndex()
Definition: chain.h:214
int Height() const
Definition: chain.h:455
unsigned int nPos
Definition: flatfile.h:17
CBlockIndex * Genesis() const
Definition: chain.h:419
void SerializationOp(Stream &s, Operation ser_action)
Definition: chain.h:54
int nFile
Which # file this block is stored in (blk?????.dat)
Definition: chain.h:155
std::string ToString() const
Definition: uint256.cpp:61
uint256 GetBlockHash() const
Definition: chain.h:388
CBlockFileInfo()
Definition: chain.h:74
Definition: arith_uint256.h:252
block data in blk*.data was received with a witness-enforcing client
Definition: chain.h:131
int64_t GetBlockProofEquivalentTime(const CBlockIndex &to, const CBlockIndex &from, const CBlockIndex &tip, const Consensus::Params &)
Definition: chain.cpp:137
Definition: uint256.h:121
CBlockLocator GetLocator(const CBlockIndex *pindex=nullptr) const
Definition: chain.cpp:23
unsigned int nBlocks
number of blocks stored in file
Definition: chain.h:43
friend bool operator==(const CChain &a, const CChain &b)
Definition: chain.h:436
CBlockIndex * Next(const CBlockIndex *pindex) const
Definition: chain.h:447
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
Definition: chain.cpp:111
int nFile
Definition: flatfile.h:16
CBlockIndex * FindEarliestAtLeast(int64_t nTime, int height) const
Definition: chain.cpp:62
uint256 GetBlockHash() const
Definition: chain.h:261
void SetNull()
Definition: chain.h:64
unsigned int nChainTx
Definition: chain.h:173
bool HaveTxsDownloaded() const
Definition: chain.h:273
CBlockIndex * Tip() const
Definition: chain.h:424
signed long long int64_t
Definition: stdint.h:18
int64_t GetMedianTimePast() const
Definition: chain.h:287
BlockStatus
Definition: chain.h:94
All validity bits.
Definition: chain.h:120
int64_t GetBlockTime() const
Definition: chain.h:275
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition: chain.h:146
static constexpr int64_t MAX_FUTURE_BLOCK_TIME
Definition: chain.h:22
static constexpr int nMedianTimeSpan
Definition: chain.h:285
signed int int32_t
Definition: stdint.h:17
unsigned int nHeightFirst
lowest height of block in file
Definition: chain.h:46
full block available in blk*.dat
Definition: chain.h:123
FlatFilePos GetBlockPos() const
Definition: chain.h:230
#define READWRITE(...)
Definition: serialize.h:184
unsigned int nDataPos
Byte offset within blk?????.dat where this block's data is stored.
Definition: chain.h:158
void BuildSkip()
Build the skiplist pointer for this entry.
Definition: chain.cpp:116
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:152
ADD_SERIALIZE_METHODS
Definition: chain.h:361
static constexpr int64_t MAX_BLOCK_TIME_GAP
Definition: chain.h:38
#define VARINT(obj,...)
Definition: serialize.h:422
std::string ToString() const
Definition: chain.h:401