結(jié)構(gòu)
現(xiàn)實生活中的一個以太幣區(qū)塊

image
- hash:該區(qū)塊的hash
- size:該區(qū)塊的大小
- td: Total Difficulty
type Block struct {
header *Header
//叔塊信息,只保存叔塊的Header,不保存交易
uncles []*Header
//該區(qū)塊打包的所有的交易信息
transactions Transactions
// BlockHash
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
- Coinbase 獎勵礦工的地址,礦工賬戶,也叫Miner
- Root //PMT的根節(jié)點的Hash,是以太坊stateTree,存儲了所有賬戶的余額信息、Address信息、合約信息
- TxHash //PMT樹,所有的交易信息都存在這個里面
- ReceiptHash //PMT樹,所有的轉(zhuǎn)賬收款信息都在這里面
- Difficulty //該區(qū)塊的難度
- Number :所有祖先區(qū)塊的數(shù)量(也就是區(qū)塊高度)
- GasLimit:該區(qū)塊的gas上限
- GasUsed:該區(qū)塊使用的gas
- Time:區(qū)塊開始打包的時間
- MixDigest:該哈希值與Nonce值一起能夠證明在該區(qū)塊上已經(jīng)進行了足夠的計算(用于驗證該區(qū)塊挖礦成功與否的Hash值
- Nonce: 該哈希值與MixDigest值一起能夠證明在該區(qū)塊上已經(jīng)進行了足夠的計算(用于驗證該區(qū)塊挖礦成功與否的Hash值
// 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"`
MixDigest common.Hash `json:"mixHash"`
Nonce BlockNonce `json:"nonce"`
}
其它
- BlockNonce 64位哈希,足夠生成一個區(qū)塊了
- Address賬號地址在以太坊中就是20byte的字節(jié)
//go里面 type byte = uint8
//BlockNone是一個64位哈希,它證明(與//Mix-散列)已進行了足夠數(shù)量的計算//在一個區(qū)塊外。
type BlockNonce [8]byte
// Address represents the 20 byte address of an Ethereum account.
type Address [AddressLength]byte