Blocks and the Blockchain

Each DeFiChain block consists of

  • a block header: contains metadata about the block and its contents and links to previous block
  • a body: contains a list of transactions in that block.

Blocks are identified by their SHA256 hashes.

Block header

The header format of DeFiChain blocks is as follows. The implementation of the block header can be found in the class CBlockHeader in file src/primitives/block.h.

NameData TypeDescription
nVersionint32_tUsed to create and accept soft forks. Usually 536870912. For details on how nVersion is processed and used, read BIP9.
hashPrevBlockuint256Double SHA256 hash of previous block header.
hashMerkleRootuint256Double SHA256 hash of merkle root of transaction merkle tree.
nTimeuint32_tUnix time of when the miner started hashing the header (according to the miner). Must be strictly greater than the median time of the previous 11 blocks.
nBitsuint32_tUsed for PoS mining. An encoded version of the target threshold this block’s header hash must be less than or equal to.
deprecatedHeight*uint64_t[*No longer in use] Block height of the current block. Block height is tracked by CBlockIndex instead of block headers themselves, this remains in the block header for compatibility with previous versions of the node. Removal of this field would require a hard fork.
mintedBlocksuint64_tNumber of blocks this masternode has mined.
stakeModifieruint256A stake modifier is a collective source of random entropy for PoS mining. It is equal to SHA256({previous stake modifier}, {masternode ID}).
sigvectorSigned digest block header using miner's public key.

Block Body

The block body consists of

  • a list of pointers which map to transactions
  • a local variable fChecked (not shared between nodes) to track if the block has been successfully validated previously

The list of transactions has type vector<CTransactionRef>, and each CTransactionRef points to a CTransaction. The contents of each Transaction as well as the different types of Transactions are detailed in the Transactions document.

External Resources