以太坊的Block數(shù)據(jù)分成Header和Body卤妒,分開存儲于db.
Header的數(shù)據(jù)結(jié)構(gòu):
// Header represents a block header in the Ethereum blockchain.
type Header struct {
//父區(qū)塊hash
ParentHash common.Hash `json:"parentHash" gencodec:"required"`
UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"`
//打包區(qū)塊的地址
Coinbase common.Address `json:"miner" gencodec:"required"`
Root common.Hash `json:"stateRoot" gencodec:"required"`
TxHash common.Hash `json:"transactionsRoot" gencodec:"required"`
ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"`
Bloom Bloom `json:"logsBloom" gencodec:"required"`
//難度
Difficulty *big.Int `json:"difficulty" gencodec:"required"`
//區(qū)塊高度
Number *big.Int `json:"number" gencodec:"required"`
GasLimit uint64 `json:"gasLimit" gencodec:"required"`
GasUsed uint64 `json:"gasUsed" gencodec:"required"`
Time *big.Int `json:"timestamp" gencodec:"required"`
Extra []byte `json:"extraData" gencodec:"required"`
//pow共識最終計算出的比Difficulty小的hash
//digest, result := hashimotoFull(dataset.dataset, hash, nonce)
MixDigest common.Hash `json:"mixHash" gencodec:"required"`
//pow共識算法計算出的值
Nonce BlockNonce `json:"nonce" gencodec:"required"`
}
Body的數(shù)據(jù)結(jié)構(gòu):
// Body is a simple (mutable, non-safe) data container for storing and moving
// a block's data contents (transactions and uncles) together.
type Body struct {
Transactions []*Transaction
Uncles []*Header
}