[#CDiskBlockIndex]
= CDiskBlockIndex
:mrdocs:

Used to marshal pointers into hashes for db storage&period;

== Synopsis

Declared in `&lt;chain&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class CDiskBlockIndex
    : public xref:CBlockIndex.adoc[CBlockIndex]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:CBlockIndex.adoc[CBlockIndex]`
| The block chain is a tree shaped structure starting with the genesis block at the root, with each block potentially having multiple candidates to be the next block&period; A blockindex may have multiple pprev pointing to it, but at most one of them can be part of the currently active branch&period;
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CDiskBlockIndex/2constructor-07.adoc[`CDiskBlockIndex`]         [.small]#[constructor]#
| Constructors
| xref:CBlockIndex/BuildSkip.adoc[`BuildSkip`] 
| Build the skiplist pointer for this entry&period;
| xref:CDiskBlockIndex/ConstructBlockHash.adoc[`ConstructBlockHash`] 
| Recomputes the block hash from the stored header fields&period;
| xref:CBlockIndex/GetAncestor-0f.adoc[`GetAncestor`] 
| `GetAncestor` overloads
| xref:CDiskBlockIndex/GetBlockHash-01.adoc[`GetBlockHash`] 
| `GetBlockHash` overloads
| xref:CBlockIndex/GetBlockHeader.adoc[`GetBlockHeader`] 
| Reconstructs the block header for this entry&period;
| xref:CBlockIndex/GetBlockPos.adoc[`GetBlockPos`] 
| Returns the on&hyphen;disk position of this block&apos;s data&period;
| xref:CBlockIndex/GetBlockTime.adoc[`GetBlockTime`] 
| Returns this block&apos;s timestamp&period;
| xref:CBlockIndex/GetBlockTimeMax.adoc[`GetBlockTimeMax`] 
| Returns the maximum timestamp seen in the chain up to and including this block&period;
| xref:CBlockIndex/GetMedianTimePast.adoc[`GetMedianTimePast`] 
| Returns the median timestamp of the previous nMedianTimeSpan blocks&period;
| xref:CBlockIndex/GetUndoPos.adoc[`GetUndoPos`] 
| Returns the on&hyphen;disk position of this block&apos;s undo data&period;
| xref:CBlockIndex/HaveNumChainTxs.adoc[`HaveNumChainTxs`] 
| Check whether this block and all previous blocks back to the genesis block or an assumeutxo snapshot block have reached VALID&lowbar;TRANSACTIONS and had transactions downloaded (and stored to disk) at some point&period;
| xref:CBlockIndex/IsValid.adoc[`IsValid`] 
| Check whether this block index entry is valid up to the passed validity level&period;
| xref:CBlockIndex/RaiseValidity.adoc[`RaiseValidity`] 
| Raise the validity level of this block index entry&period; Returns true if the validity was changed&period;
| xref:CBlockIndex/Time.adoc[`Time`] 
| Returns this block&apos;s timestamp as a time point&period;
| xref:CDiskBlockIndex/ToString-03.adoc[`ToString`] 
| `ToString` overloads
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CBlockIndex/hashMerkleRoot.adoc[`hashMerkleRoot`] 
| Merkle root of the block&apos;s transactions
| xref:CDiskBlockIndex/hashPrev.adoc[`hashPrev`] 
| Hash of the predecessor block, stored explicitly for on&hyphen;disk serialization&period;
| xref:CBlockIndex/m_chain_tx_count.adoc[`m&lowbar;chain&lowbar;tx&lowbar;count`] 
| (memory only) Number of transactions in the chain up to and including this block&period; This value will be non&hyphen;zero if this block and all previous blocks back to the genesis block or an assumeutxo snapshot block have reached the VALID&lowbar;TRANSACTIONS level&period;
| xref:CBlockIndex/nBits.adoc[`nBits`] 
| Compact&hyphen;encoded proof&hyphen;of&hyphen;work difficulty target
| xref:CBlockIndex/nChainWork.adoc[`nChainWork`] 
| (memory only) Total amount of work (expected number of hashes) in the chain up to and including this block
| xref:CBlockIndex/nDataPos.adoc[`nDataPos`] 
| Byte offset within blk?????&period;dat where this block&apos;s data is stored
| xref:CBlockIndex/nFile.adoc[`nFile`] 
| Which &num; file this block is stored in (blk?????&period;dat)
| xref:CBlockIndex/nHeight.adoc[`nHeight`] 
| height of the entry in the chain&period; The genesis block has height 0
| xref:CBlockIndex/nNonce.adoc[`nNonce`] 
| Proof&hyphen;of&hyphen;work nonce
| xref:CBlockIndex/nSequenceId.adoc[`nSequenceId`] 
| (memory only) Sequential id assigned to distinguish order in which blocks are received&period; Initialized to SEQ&lowbar;ID&lowbar;INIT&lowbar;FROM&lowbar;DISK&lcub;1&rcub; when loading blocks from disk, except for blocks belonging to the best chain which overwrite it to SEQ&lowbar;ID&lowbar;BEST&lowbar;CHAIN&lowbar;FROM&lowbar;DISK&lcub;0&rcub;&period;
| xref:CBlockIndex/nStatus.adoc[`nStatus`] 
| Verification status of this block&period; See enum BlockStatus
| xref:CBlockIndex/nTime.adoc[`nTime`] 
| Block timestamp, in seconds since the Unix epoch
| xref:CBlockIndex/nTimeMax.adoc[`nTimeMax`] 
| (memory only) Maximum nTime in the chain up to and including this block&period;
| xref:CBlockIndex/nTx.adoc[`nTx`] 
| Number of transactions in this block&period; This will be nonzero if the block reached the VALID&lowbar;TRANSACTIONS level, and zero otherwise&period; Note&colon; in a potential headers&hyphen;first mode, this number cannot be relied upon
| xref:CBlockIndex/nUndoPos.adoc[`nUndoPos`] 
| Byte offset within rev?????&period;dat where this block&apos;s undo data is stored
| xref:CBlockIndex/nVersion.adoc[`nVersion`] 
| block header
| xref:CBlockIndex/phashBlock.adoc[`phashBlock`] 
| pointer to the hash of the block, if any&period; Memory is owned by this CBlockIndex
| xref:CBlockIndex/pprev.adoc[`pprev`] 
| pointer to the index of the predecessor of this block
| xref:CBlockIndex/pskip.adoc[`pskip`] 
| pointer to the index of some further predecessor of this block
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CBlockIndex/nMedianTimeSpan.adoc[`nMedianTimeSpan`] 
| Number of blocks considered when computing the median time past&period;
|===


== Protected Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CBlockIndex/operator_assign-03.adoc[`operator&equals;`] 
| Assignment operators
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CalculateLockPointsAtTip.adoc[`CalculateLockPointsAtTip`]
| Calculate LockPoints required to check if transaction will be BIP68 final in the next block to be created on top of tip&period;
| xref:CalculateNextWorkRequired.adoc[`CalculateNextWorkRequired`]
| Compute the retargeted proof&hyphen;of&hyphen;work target after a difficulty adjustment interval&period;
| xref:CheckFinalTxAtTip.adoc[`CheckFinalTxAtTip`]
| Check if transaction will be final in the next block to be created&period;
| xref:CheckSequenceLocksAtTip.adoc[`CheckSequenceLocksAtTip`]
| Check if transaction will be BIP68 final in the next block to be created on top of tip&period;
| xref:DeploymentActiveAfter-07.adoc[`DeploymentActiveAfter`]
| Determine if a deployment is active for the next block
| xref:DeploymentActiveAfter-0b.adoc[`DeploymentActiveAfter`]
| Determine if a version&hyphen;bits deployment is active for the next block&period;
| xref:DeploymentActiveAfter-0d.adoc[`DeploymentActiveAfter`]
| Whether a deployment is active after the given block, resolved via ChainstateManager&period;
| xref:DeploymentActiveAt-01d.adoc[`DeploymentActiveAt`]
| Determine if a version&hyphen;bits deployment is active for this block&period;
| xref:DeploymentActiveAt-05.adoc[`DeploymentActiveAt`]
| Whether a deployment is active at the given block, resolved via ChainstateManager&period;
| xref:DeploymentActiveAt-0d.adoc[`DeploymentActiveAt`]
| Determine if a deployment is active for this block
| xref:EvaluateSequenceLocks.adoc[`EvaluateSequenceLocks`]
| Checks whether previously computed sequence locks are satisfied by a block&period;
| xref:GetBlockProof-0f.adoc[`GetBlockProof`]
| Compute how much work a block index entry corresponds to&period;
| xref:GetBlockProofEquivalentTime.adoc[`GetBlockProofEquivalentTime`]
| Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds&period;
| xref:GetBlockScriptFlags.adoc[`GetBlockScriptFlags`]
| Return the script flags which should be checked for a given block&period;
| xref:GetDifficulty.adoc[`GetDifficulty`]
| Get the difficulty of the net wrt to the given block index&period;
| xref:GetLocator.adoc[`GetLocator`]
| Get a locator for a block index entry&period;
| xref:GetNextWorkRequired.adoc[`GetNextWorkRequired`]
| Compute the proof&hyphen;of&hyphen;work target (nBits) required for the block following pindexLast&period;
| xref:GetTarget.adoc[`GetTarget`]
| &ast; Get the target for a given block index&period;
| xref:IsBIP30Repeat.adoc[`IsBIP30Repeat`]
| Identifies blocks that overwrote an existing coinbase output in the UTXO set (see BIP30)&period;
| xref:LastCommonAncestor.adoc[`LastCommonAncestor`]
| Find the forking point between two chain tips&period;
| xref:LocatorEntries.adoc[`LocatorEntries`]
| Construct a list of hash entries to put in a locator&period;
| xref:NextEmptyBlockIndex.adoc[`NextEmptyBlockIndex`]
| Return an empty block index on top of the tip, with height, time and nBits set
| xref:blockheaderToJSON.adoc[`blockheaderToJSON`]
| Block header to JSON
| xref:kernel/MakeBlockInfo.adoc[`kernel&colon;&colon;MakeBlockInfo`]
| Builds block metadata from a block index entry&period;
| xref:node/GetMinimumTime.adoc[`node&colon;&colon;GetMinimumTime`]
| Get the minimum time a miner should use in the next block&period; This always accounts for the BIP94 timewarp rule, so does not necessarily reflect the consensus limit&period;
| xref:node/GetTransaction.adoc[`node&colon;&colon;GetTransaction`]
| Return transaction with a given hash&period; If mempool is provided and block&lowbar;index is not provided, check it first for the tx&period; If &hyphen;txindex is available, check it next for the tx&period; Finally, if block&lowbar;index is provided, check for tx by reading entire block from disk&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
