title: ETH区块数据结构解析
date: 2020-02-1 20:50:49
tags: Bitcoin
categories: 区块结构
区块的源码
// 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:区块头,包含该区块的信息
- uncles:该区块所包含的叔块的信息
- transactions:该区块包含的交易信息
- td:总难度,即从开始区块到本区块(包括本区块)所有的难度的累加
- ReceivedAt:用于跟踪区块的生成
- ReceivedFrom:用于跟踪区块的生成
结构图:
各部分代表的含义
- ParentHash:父区块的哈希值
- UncleHash:上面提到的uncles的RLP哈希值,uncles是一个Header数组
- Coinbase:挖出该区块矿工的地址,矿工费和挖出区块的奖励会发放到该地址
- Root:
- TxHash:存储该区块中交易的Merkle树的根节点的哈希
- ReceiptHash:存储该区块的交易的回单的Merkle树的根节点的哈希,Block的所有Transaction执行完后会生成一个Receipt数组
- Bloom:交易日志的布隆过滤器,用于查询
- Difficulty:区块的难度
- Number:区块高度
- Time:挖出该区块的时间戳
- GasLimit:区块内所有Gas消耗的上限
- GasUsed:执行区块内所有Transaction实际消耗的Gas总和
- Nonce:一个64bit的哈希数,用于工作量证明
- mixDigest:该哈希值与Nonce值一起证明该区块上已经进行了足够的计算,用于证明挖矿成功
- Extra:预留备用
小结
以太坊各个方面我也不太清楚,只能靠着自己了解的写一下,transaction的结构图没有给出,慢慢来吧,等我了解清楚再更新!