美文网首页
ETH源码阅读(Block的Header和Body)

ETH源码阅读(Block的Header和Body)

作者: 坠叶飘香 | 来源:发表于2018-09-20 14:45 被阅读0次

    以太坊的Block数据分成Header和Body,分开存储于db.

    Header的数据结构:
    // Header represents a block header in the Ethereum blockchain.
    type Header struct {
            //父区块hash
        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"`
            
            //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的数据结构:
    // 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
    }
    

    相关文章

      网友评论

          本文标题:ETH源码阅读(Block的Header和Body)

          本文链接:https://www.haomeiwen.com/subject/irpgnftx.html