 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
8 #ifndef BITCOIN_CHAIN_H
9 #define BITCOIN_CHAIN_H
31 template <
typename Stream,
typename Operation>
32 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion)
62 void AddBlock(
unsigned int nHeightIn, uint64_t nTimeIn)
82 template <
typename Stream,
typename Operation>
83 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion)
366 return (int64_t)
nTime;
381 std::sort(pbegin, pend);
382 return pbegin[(pend - pbegin) / 2];
434 if (fGeneratedStakeModifier)
447 return strprintf(
"CBlockIndex(pprev=%p, nHeight=%d, merkle=%s, hashBlock=%s)",
509 template <
typename Stream,
typename Operation>
573 std::string str =
"CDiskBlockIndex(";
575 str +=
strprintf(
"\n hashBlock=%s, hashPrev=%s)",
605 pindex = pindex->
pprev;
613 if (nHeight < 0 || nHeight >= (
int)
vChain.size())
621 return a.
vChain.size() ==
b.vChain.size() &&
628 return (*
this)[pindex->
nHeight] == pindex;
635 return (*
this)[pindex->
nHeight + 1];
656 #endif // BITCOIN_CHAIN_H
int64_t GetBlockTime() const
CBlockIndex * pnext
pointer to the index of the next block
@ BLOCK_FAILED_CHILD
stage after last reached validness failed
const uint256 UINT256_ZERO
constant uint256 instances
bool RaiseValidity(enum BlockStatus nUpTo)
Raise the validity level of this block index entry.
bool IsProofOfStake() const
uint64_t nTimeFirst
highest height of block in file
int nFile
Which # file this block is stored in (blk?????.dat)
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
const uint256 * phashBlock
pointer to the hash of the block, if any. memory is owned by this CBlockIndex
bool SetStakeEntropyBit(unsigned int nEntropyBit)
unsigned int nTx
Number of transactions in this block.
@ BLOCK_FAILED_MASK
descends from failed block
CBlockIndex * pprev
pointer to the index of the predecessor of this block
int nHeight
height of the entry in the chain. The genesis block has height 0
@ BLOCK_VALID_TREE
All parent headers found, difficulty matches, timestamp >= median previous, checkpoint.
unsigned int GetStakeEntropyBit() const
@ BLOCK_HAVE_MASK
undo data available in rev*.dat
std::string ToString() const
CDiskBlockIndex(const CBlockIndex *pindex)
uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
unsigned int nChainTx
(memory only) Number of transactions in the chain up to and including this block.
unsigned int nDataPos
Byte offset within blk?????.dat where this block's data is stored.
friend bool operator!=(const CDiskBlockPos &a, const CDiskBlockPos &b)
Used to marshal pointers into hashes for db storage.
unsigned int nStatus
Verification status of this block. See enum BlockStatus.
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
CBlockIndex * pskip
pointer to the index of some further predecessor of this block
@ BLOCK_VALID_MASK
All validity bits.
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Find the last common block between this chain and a block index entry.
@ BLOCK_VALID_HEADER
Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future.
CDiskBlockPos(int nFileIn, unsigned int nPosIn)
uint64_t GetCheapHash() const
CBlockHeader GetBlockHeader() const
@ BLOCK_VALID_TRANSACTIONS
Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid,...
uint64_t nTimeLast
earliest time of block in file
static bool IsSuperMajority(int minVersion, const CBlockIndex *pstart, unsigned int nRequired)
Returns true if there are nRequired or more blocks of minVersion or above in the last Params()....
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
@ BLOCK_VALID_UNKNOWN
Unused.
int64_t GetMedianTimePast() const
unsigned int nHeightFirst
number of used bytes in the undo file
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
Check whether this block index entry is valid up to the passed validity level.
std::string ToString() const
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
bool IsProofOfWork() const
256-bit unsigned big integer.
bool GeneratedStakeModifier() const
friend bool operator==(const CDiskBlockPos &a, const CDiskBlockPos &b)
unsigned int nHeightLast
lowest height of block in file
void AddBlock(unsigned int nHeightIn, uint64_t nTimeIn)
update statistics (does not update nSize)
unsigned int nStakeModifierChecksum
@ BLOCK_VALID_SCRIPTS
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
void SetTip(CBlockIndex *pindex)
Set/initialize a chain with a given tip.
uint256 GetBlockHash() const
int Height() const
Return the maximal height in the chain.
ADD_SERIALIZE_METHODS
latest time of block in file
uint256 nAccumulatorCheckpoint
std::vector< CTransaction > vtx
An in-memory indexed chain of blocks.
CBlockLocator GetLocator(const CBlockIndex *pindex=NULL) const
Return a CBlockLocator that refers to a block in this chain (by default the tip).
CDiskBlockPos GetBlockPos() const
unsigned int nUndoPos
Byte offset within rev?????.dat where this block's undo data is stored.
void BuildSkip()
Build the skiplist pointer for this entry.
std::vector< CBlockIndex * > vChain
uint32_t nSequenceId
(memory only) Sequential id assigned to distinguish order in which blocks are received.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
unsigned int nUndoSize
number of used bytes of block file
uint256 hashPoAMerkleRoot
PoA block header.
uint256 GetBlockHash() const
bool IsProofOfAudit() const
An outpoint - a combination of a transaction hash and an index n into its vout.
CBlockIndex(const CBlock &block)
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or NULL if none.
bool IsProofOfAudit() const
std::string ToString() const
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
The block chain is a tree shaped structure starting with the genesis block at the root,...
@ BLOCK_VALID_CHAIN
Outputs do not overspend inputs, no double spends, coinbase output ok, immature coinbase spends,...
uint256 GetBlockTrust() const
CBlockIndex * operator[](int nHeight) const
Returns the index entry at a particular height in this chain, or NULL if no such height exists.
unsigned int nSize
number of blocks stored in file
void SetStakeModifier(uint64_t nModifier, bool fGeneratedStakeModifier)
@ BLOCK_HAVE_UNDO
full block available in blk*.dat
CDiskBlockPos GetUndoPos() const
friend bool operator==(const CChain &a, const CChain &b)
Compare two chains efficiently.
CBlockIndex * Next(const CBlockIndex *pindex) const
Find the successor of a block in this chain, or NULL if the given index is not found or is the tip.
bool IsProofOfStake() const
CBlockIndex * Genesis() const
Returns the index entry for the genesis block of this chain, or NULL if none.
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
std::string ToString() const