The Blockchain is a data structure. The block is composed of block header and block body. As each block has a crpytographic hash of the previous block (refer to
PrevHash in the block header), and a chain structure is formed.
The data structure of block as following:
|Block version, current is
|The previous block's hash
|Merkle Tree Root
|The merkle tree root of the block's transactions
|The time when this block is generated
|The random number of the block
|Block height, and the Genesis Block's index is 0
|Index of the proposal validator in the current round
|Address of the next round validator
|The script hash of more than two-thirds of validator's signatures for the next round
|The executable verification scripts
The block header contains the basic information of a block and provides verification of a block.
index can be used to identify a block. The hash value is obtained by concatenating the first seven attributes of the block header and performing SHA256 operation twice. Normally, Neo has only one chain, and each block is confirmed by more than two-thirds of the consensus nodes, before added to the blockchain. Therefore, the height of each block is unique. Block height must be equal to the previous block height plus 1, and the Genesis Block height is 0.
Timestamp is the block's time stamp, must be bigger than the previous one. The internal between two blocks is about 15 seconds, and is set by the variable
MillisecondsPerBlock in the configuration file
NextConsensus is the hash of multi-signature contract, which needs the signatures of more than two-thirds of the consensus nodes as parameters. The example script is shown as below. Each block, with the
NextConsensus field, locks the nodes participating in the next round of consensus activity. In the previous round of consensus activity, the Speaker calculated the consensus nodes of the next round based on the voting at that time, generated the multi-signature contract, and assigned the hash value of the contract to the block's
Witness is the verification script of the block, it contains
InvocationScript provides the parameters for the
VerificationScript to execute.
The block data structure is as follows:
|The payload of the block
The block body is a transaction list, which essentially starts with the transaction list length, followed by a list of transactions. In one round of consensus activity, the Speaker selects a series of verified transactions from its memory pool, put the transaction hash into a consensus message (
PrePareRequest) and then broadcast it to the blockchain network. For more details about consensus, refer to Consensus Mechanism.
At present, there can be up to 512 transactions per block.
When a block persistent, it stores a hash list of the block's transaction, and the transaction data is stored separately to facilitate queries.