github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/protocol/bc/types/block_commitment.go (about)

     1  package types
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/bytom/bytom/encoding/blockchain"
     7  	"github.com/bytom/bytom/protocol/bc"
     8  )
     9  
    10  // BlockCommitment store the TransactionsMerkleRoot
    11  type BlockCommitment struct {
    12  	// TransactionsMerkleRoot is the root hash of the Merkle binary hash tree
    13  	// formed by the hashes of all transactions included in the block.
    14  	TransactionsMerkleRoot bc.Hash `json:"transaction_merkle_root"`
    15  }
    16  
    17  func (bc *BlockCommitment) readFrom(r *blockchain.Reader) error {
    18  	_, err := bc.TransactionsMerkleRoot.ReadFrom(r)
    19  	return err
    20  }
    21  
    22  func (bc *BlockCommitment) writeTo(w io.Writer) error {
    23  	_, err := bc.TransactionsMerkleRoot.WriteTo(w)
    24  	return err
    25  }