Block數(shù)據(jù)結(jié)構(gòu)解析
源代碼
// Block represents an entire block in the Ethereum blockchain.
type Block struct {
? ? header???????*Header
? ? uncles???????[]*Header
? ? transactions Transactions
? ? // caches
? ? hash atomic.Value
? ? size atomic.Value
? ? // Td is used by package core to store the total difficulty
????// of the chain up to and including the block.
? ? td *big.Int
? ? // These fields are used by package eth to track
? ? // inter-peer block relay.
? ? ReceivedAt???time.Time
? ? ReceivedFrom interface{}
}
主要屬性:
- header: ? ? ? ? ?該區(qū)塊的信息
- uncles: ? ? ? ? ? 該區(qū)塊所包含的叔塊的信息
- transactions: ?該區(qū)塊所包含的交易信息
- td: ? ? ? ? ? ? ? ? ? 總難度,即從開始區(qū)塊到本區(qū)塊(包括本區(qū)塊)所有的難度的累加
- ReceivedAt: ? ? 用于跟蹤區(qū)塊的生成 ? ? ??
- ReceivedFrom:用于跟蹤區(qū)塊的生成
Header數(shù)據(jù)結(jié)構(gòu)解析
源代碼
// Header represents a block header in the Ethereum blockchain.
type Header struct {
???ParentHash? common.Hash??? `json:"parentHash"?gencodec:"required"`
???UncleHash?? common.Hash??? `json:"sha3Uncles"?gencodec:"required"`
???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"`
???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"`
???Extra2????? []byte?`json:"extraData2"?gencodec:"required"`
???MixDigest?? common.Hash??? `json:"mixHash"?gencodec:"required"`
???Nonce?????? BlockNonce???? `json:"nonce"?gencodec:"required"`
}
主要屬性:
- ParentHash: ?該區(qū)塊的父區(qū)塊的哈希值
- UncleHash: ? 該區(qū)塊所包含的叔塊的哈希值
- Coinbase: ? ? 打包該區(qū)塊礦工的地址,礦工費(fèi)和打包區(qū)塊的獎(jiǎng)金將發(fā)送到這個(gè)地址
- Root: ? ? ? ? ? ? 存儲(chǔ)賬戶狀態(tài)的Merkle樹的根節(jié)點(diǎn)的哈希
- TxHash: ? ? ? ?存儲(chǔ)該區(qū)塊中的交易的Merkle樹的根節(jié)點(diǎn)的哈希
- ReceiptHash:存儲(chǔ)該區(qū)塊的交易的回單的Merkle樹的根節(jié)點(diǎn)的哈希
- Bloom: ? ? ? ? ?交易日志的布隆過(guò)濾器,用于查詢
- Difficulty: ? ? ? 該區(qū)塊的難度
- Number: ? ? ? 區(qū)塊號(hào),也是區(qū)塊高度,也是所有祖先區(qū)塊的數(shù)量
- GasLimit: ? ? ?該區(qū)塊的汽油(gas)上限
- GasUsed: ? ? 該區(qū)塊使用的汽油(gas)
- Time: ? ? ? ? ? ?區(qū)塊開始打包時(shí)間戳(調(diào)用Engine.Prepare函數(shù)的時(shí)候設(shè)置)
- MixDigest: ? ?該哈希值與Nonce值一起證明該區(qū)塊上已經(jīng)進(jìn)行了足夠的計(jì)算,用于證明挖礦成功
- Nonce: ? ? ? ? 該哈希值與MixDigest哈希值一起證明該區(qū)塊上已經(jīng)進(jìn)行了足夠的計(jì)算,用于證明挖礦成功
- Extra: ? ? ? ? ? 預(yù)留它用(例如Clique共識(shí)機(jī)制使用)