Changeset View
Changeset View
Standalone View
Standalone View
src/chain.h
Show First 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | public: | ||||
uint32_t nTime; | uint32_t nTime; | ||||
uint32_t nBits; | uint32_t nBits; | ||||
uint32_t nNonce; | uint32_t nNonce; | ||||
//! (memory only) Sequential id assigned to distinguish order in which | //! (memory only) Sequential id assigned to distinguish order in which | ||||
//! blocks are received. | //! blocks are received. | ||||
int32_t nSequenceId; | int32_t nSequenceId; | ||||
//! (memory only) block header metadata | |||||
uint64_t nTimeReceived; | |||||
//! (memory only) Maximum nTime in the chain upto and including this block. | //! (memory only) Maximum nTime in the chain upto and including this block. | ||||
unsigned int nTimeMax; | unsigned int nTimeMax; | ||||
void SetNull() { | void SetNull() { | ||||
phashBlock = nullptr; | phashBlock = nullptr; | ||||
pprev = nullptr; | pprev = nullptr; | ||||
pskip = nullptr; | pskip = nullptr; | ||||
nHeight = 0; | nHeight = 0; | ||||
nFile = 0; | nFile = 0; | ||||
nDataPos = 0; | nDataPos = 0; | ||||
nUndoPos = 0; | nUndoPos = 0; | ||||
nChainWork = arith_uint256(); | nChainWork = arith_uint256(); | ||||
nTx = 0; | nTx = 0; | ||||
nChainTx = 0; | nChainTx = 0; | ||||
nStatus = 0; | nStatus = 0; | ||||
nSequenceId = 0; | nSequenceId = 0; | ||||
nTimeMax = 0; | nTimeMax = 0; | ||||
nVersion = 0; | nVersion = 0; | ||||
hashMerkleRoot = uint256(); | hashMerkleRoot = uint256(); | ||||
nTime = 0; | nTime = 0; | ||||
nTimeReceived = 0; | |||||
nBits = 0; | nBits = 0; | ||||
nNonce = 0; | nNonce = 0; | ||||
} | } | ||||
CBlockIndex() { SetNull(); } | CBlockIndex() { SetNull(); } | ||||
CBlockIndex(const CBlockHeader &block) { | CBlockIndex(const CBlockHeader &block) { | ||||
SetNull(); | SetNull(); | ||||
nVersion = block.nVersion; | nVersion = block.nVersion; | ||||
hashMerkleRoot = block.hashMerkleRoot; | hashMerkleRoot = block.hashMerkleRoot; | ||||
nTime = block.nTime; | nTime = block.nTime; | ||||
// Default to block time if nTimeReceived is never set, which | |||||
// in effect assumes that this block is honestly mined. | |||||
// Note that nTimeReceived isn't written to disk, so blocks read from | |||||
// disk will be assumed to be honestly mined. | |||||
nTimeReceived = block.nTime; | |||||
nBits = block.nBits; | nBits = block.nBits; | ||||
nNonce = block.nNonce; | nNonce = block.nNonce; | ||||
} | } | ||||
CDiskBlockPos GetBlockPos() const { | CDiskBlockPos GetBlockPos() const { | ||||
CDiskBlockPos ret; | CDiskBlockPos ret; | ||||
if (nStatus & BLOCK_HAVE_DATA) { | if (nStatus & BLOCK_HAVE_DATA) { | ||||
ret.nFile = nFile; | ret.nFile = nFile; | ||||
Show All 25 Lines | public: | ||||
} | } | ||||
uint256 GetBlockHash() const { return *phashBlock; } | uint256 GetBlockHash() const { return *phashBlock; } | ||||
int64_t GetBlockTime() const { return int64_t(nTime); } | int64_t GetBlockTime() const { return int64_t(nTime); } | ||||
int64_t GetBlockTimeMax() const { return int64_t(nTimeMax); } | int64_t GetBlockTimeMax() const { return int64_t(nTimeMax); } | ||||
int64_t GetHeaderTimeReceived() const { return nTimeReceived; } | |||||
enum { nMedianTimeSpan = 11 }; | enum { nMedianTimeSpan = 11 }; | ||||
int64_t GetMedianTimePast() const { | int64_t GetMedianTimePast() const { | ||||
int64_t pmedian[nMedianTimeSpan]; | int64_t pmedian[nMedianTimeSpan]; | ||||
int64_t *pbegin = &pmedian[nMedianTimeSpan]; | int64_t *pbegin = &pmedian[nMedianTimeSpan]; | ||||
int64_t *pend = &pmedian[nMedianTimeSpan]; | int64_t *pend = &pmedian[nMedianTimeSpan]; | ||||
const CBlockIndex *pindex = this; | const CBlockIndex *pindex = this; | ||||
▲ Show 20 Lines • Show All 222 Lines • Show Last 20 Lines |