30 static constexpr int64_t TIMESTAMP_WINDOW = 2 * 60 * 60;
73 void AddBlock(
unsigned int nHeightIn, uint64_t nTimeIn)
232 void SetStakeModifier(
const uint64_t nStakeModifier,
bool fGeneratedStakeModifier);
260 static const int DBI_OLD_SER_VERSION = 4009900;
261 static const int DBI_SER_VERSION_NO_ZC = 4009902;
280 int nSerVersion = s.GetVersion();
290 if (nSerVersion >= DBI_SER_VERSION_NO_ZC) {
300 if(obj.nVersion > 3 && obj.nVersion < 7)
304 if (obj.nVersion >= 8) {
308 }
else if (nSerVersion > DBI_OLD_SER_VERSION && ser_action.ForRead()) {
310 std::map<libzerocoin::CoinDenomination, int64_t> mapZerocoinSupply;
311 int64_t nMoneySupply = 0;
321 if (obj.nVersion > 3) {
323 if (obj.nVersion < 7)
READWRITE(obj.nAccumulatorCheckpoint);
325 }
else if (ser_action.ForRead()) {
329 int64_t nMoneySupply = 0;
334 uint64_t nStakeModifier = 0;
336 SER_READ(obj, obj.SetStakeModifier(nStakeModifier, obj.GeneratedStakeModifier()));
340 SER_READ(obj, obj.SetStakeModifier(nStakeModifierV2));
342 if (obj.IsProofOfStake()) {
344 unsigned int nStakeTime = 0;
355 if (obj.nVersion > 3) {
356 std::map<libzerocoin::CoinDenomination, int64_t> mapZerocoinSupply;
357 std::vector<libzerocoin::CoinDenomination> vMintDenominationsInBlock;
384 return strprintf(
"CDiskBlockIndex(%s\n hashBlock=%s, hashPrev=%s)",
414 pindex = pindex->
pprev;
422 if (nHeight < 0 || nHeight >= (
int)
vChain.size())
437 return (*
this)[pindex->
nHeight] == pindex;
444 return (*
this)[pindex->
nHeight + 1];
int64_t CAmount
Amount in PIV (Can be negative)
@ BLOCK_VALID_CHAIN
Outputs do not overspend inputs, no double spends, coinbase output ok, immature coinbase spends.
@ BLOCK_VALID_MASK
All validity bits.
@ BLOCK_VALID_TRANSACTIONS
Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid,...
@ BLOCK_VALID_SCRIPTS
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
@ BLOCK_VALID_TREE
All parent headers found, difficulty matches, timestamp >= median previous, checkpoint.
@ BLOCK_HAVE_UNDO
full block available in blk*.dat
@ BLOCK_FAILED_CHILD
stage after last reached validness failed
@ BLOCK_FAILED_MASK
descends from failed block
@ BLOCK_VALID_HEADER
Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future.
@ BLOCK_HAVE_MASK
undo data available in rev*.dat
@ BLOCK_VALID_UNKNOWN
Unused.
const CBlockIndex * LastCommonAncestor(const CBlockIndex *pa, const CBlockIndex *pb)
Find the forking point between two chain tips.
const CChainParams & Params()
Return the currently selected parameters.
uint64_t nTimeFirst
earliest time of block in file
uint64_t nTimeLast
latest time of block in file
std::string ToString() const
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn)
update statistics (does not update nSize)
unsigned int nHeightFirst
lowest height of block in file
unsigned int nHeightLast
highest height of block in file
unsigned int nUndoSize
number of used bytes in the undo file
unsigned int nBlocks
number of blocks stored in file
SERIALIZE_METHODS(CBlockFileInfo, obj)
unsigned int nSize
number of used bytes of block file
The block chain is a tree shaped structure starting with the genesis block at the root,...
bool RaiseValidity(enum BlockStatus nUpTo)
Raise the validity level of this block index entry.
uint256 GetStakeModifierV2() const
std::string ToString() const
CBlockIndex * pprev
pointer to the index of the predecessor of this block
void BuildSkip()
Build the skiplist pointer for this entry.
unsigned int GetStakeEntropyBit() const
bool IsProofOfStake() const
std::vector< unsigned char > vStakeModifier
CBlockHeader GetBlockHeader() const
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
int nFile
Which # file this block is stored in (blk?????.dat)
FlatFilePos GetBlockPos() const
void SetNewStakeModifier()
int64_t MaxFutureBlockTime() const
uint32_t nSequenceId
(memory only) Sequential id assigned to distinguish order in which blocks are received.
unsigned int nTimeMax
(memory only) Maximum nTime in the chain upto and including this block.
void SetStakeModifier(const uint64_t nStakeModifier, bool fGeneratedStakeModifier)
bool SetStakeEntropyBit(unsigned int nEntropyBit)
bool GeneratedStakeModifier() const
bool IsProofOfWork() const
unsigned int nUndoPos
Byte offset within rev?????.dat where this block's undo data is stored.
uint256 nAccumulatorCheckpoint
uint256 GetBlockHash() const
int64_t GetBlockTime() const
void SetChainSaplingValue()
int64_t GetMedianTimePast() const
CAmount nSaplingValue
Change in value held by the Sapling circuit over this block.
CBlockIndex * pskip
pointer to the index of some further predecessor of this block
int64_t GetBlockTimeMax() const
unsigned int nTx
Number of transactions in this block.
uint256 hashFinalSaplingRoot
int64_t MinPastBlockTime() const
FlatFilePos GetUndoPos() const
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
Check whether this block index entry is valid up to the passed validity level.
int32_t nVersion
block header
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
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
unsigned int nDataPos
Byte offset within blk?????.dat where this block's data is stored.
Optional< CAmount > nChainSaplingValue
(memory only) Total value held by the Sapling circuit up to and including this block.
unsigned int nChainTx
(memory only) Number of transactions in the chain up to and including this block.
const uint256 * phashBlock
pointer to the hash of the block, if any. memory is owned by this CBlockIndex
uint64_t GetStakeModifierV1() const
An in-memory indexed chain of blocks.
CBlockIndex * Genesis() const
Returns the index entry for the genesis block of this chain, or nullptr if none.
friend bool operator==(const CChain &a, const CChain &b)
Compare two chains efficiently.
CBlockIndex * operator[](int nHeight) const
Returns the index entry at a particular height in this chain, or nullptr if no such height exists.
CBlockIndex * Next(const CBlockIndex *pindex) const
Find the successor of a block in this chain, or nullptr if the given index is not found or is the tip...
CBlockIndex * Tip(bool fProofOfStake=false) 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).
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
void SetTip(CBlockIndex *pindex)
Set/initialize a chain with a given tip.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
CBlockIndex * FindEarliestAtLeast(int64_t nTime) const
Find the earliest block with timestamp equal or greater than the given.
std::string ToString() const
SERIALIZE_METHODS(CDiskBlockIndex, obj)
CDiskBlockIndex(const CBlockIndex *pindex)
uint256 GetBlockHash() const
An outpoint - a combination of a transaction hash and an index n into its vout.
256-bit unsigned big integer.
std::string ToString() const
boost::optional< T > Optional
Substitute for C++17 std::optional.
#define VARINT_MODE(obj, mode)
#define SER_READ(obj, code)
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
const uint256 UINT256_ZERO
constant uint256 instances
bool NetworkUpgradeActive(int nHeight, const Consensus::Params ¶ms, Consensus::UpgradeIndex idx)
Returns true if the given network upgrade is active as of the given block height.