Changeset View
Changeset View
Standalone View
Standalone View
src/chain.h
Show First 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | CBlockHeader GetBlockHeader() const { | ||||
block.nTime = nTime; | block.nTime = nTime; | ||||
block.nBits = nBits; | block.nBits = nBits; | ||||
block.nNonce = nNonce; | block.nNonce = nNonce; | ||||
return block; | return block; | ||||
} | } | ||||
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); } | ||||
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]; | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | std::string ToString() const { | ||||
std::string str = "CDiskBlockIndex("; | std::string str = "CDiskBlockIndex("; | ||||
str += CBlockIndex::ToString(); | str += CBlockIndex::ToString(); | ||||
str += strprintf("\n hashBlock=%s, hashPrev=%s)", | str += strprintf("\n hashBlock=%s, hashPrev=%s)", | ||||
GetBlockHash().ToString(), hashPrev.ToString()); | GetBlockHash().ToString(), hashPrev.ToString()); | ||||
return str; | return str; | ||||
} | } | ||||
}; | }; | ||||
/** An in-memory indexed chain of blocks. */ | /** | ||||
* An in-memory indexed chain of blocks. | |||||
*/ | |||||
class CChain { | class CChain { | ||||
private: | private: | ||||
std::vector<CBlockIndex *> vChain; | std::vector<CBlockIndex *> vChain; | ||||
public: | public: | ||||
/** | /** | ||||
* Returns the index entry for the genesis block of this chain, or nullptr | * Returns the index entry for the genesis block of this chain, or nullptr | ||||
* if none. | * if none. | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |