Skip to content

Blockchain Index Directory Note

Peng edited this page Mar 20, 2017 · 2 revisions

https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage

't' + 32-byte transaction hash -> ..

To enable the automatically-maintained transaction index, one need to use

bitcoind -txindex -reindex

'b' + 32-byte block hash -> block index record. Each record stores:

The block header.

    //! block header
    int nVersion;
    uint256 hashMerkleRoot;
    unsigned int nTime;
    unsigned int nBits;
    unsigned int nNonce;

The height.

    //! height of the entry in the chain. The genesis block has height 0
    int nHeight;

The number of transactions.

    //! Number of transactions in this block.
    //! Note: in a potential headers-first mode, this number cannot be relied upon
    unsigned int nTx;

To what extent this block is validated.

    //! Verification status of this block. See enum BlockStatus
    unsigned int nStatus;

In which file, and where in that file, the block data is stored. In which file, and where in that file, the undo data is stored.

    //! Which # file this block is stored in (blk?????.dat)
    int nFile;

    //! Byte offset within blk?????.dat where this block's data is stored
    unsigned int nDataPos;

    //! Byte offset within rev?????.dat where this block's undo data is stored
    unsigned int nUndoPos;