区块链Block => Blockchain
1)概念与源码分析
// core/types/block.go
type Block struct {
// 区块的结构构成
header *Header
uncles []*Header
transactions Transactions
// 缓存cache
hash atomic.Value
size atomic.Value
// eth protocol追踪
ReceivedAt time.Time
ReceivedFrom interface{}
}
type Header struct {
ParentHash common.Hash `json:"parentHash" gencodec:"required"`
UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"`
Coinbase common.Address `json:"miner"`
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 uint64 `json:"timestamp" gencodec:"required"`
Extra []byte `json:"extraData" gencodec:"required"`
MixDigest common.Hash `json:"mixHash"`
Nonce BlockNonce `json:"nonce"`
// EIP-1559
BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"`
}
type Body struct {
Transactions []*Transaction
Uncles []*Header
}2)共识机制

image
Last updated