OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / claim / bytom / protocolbc / types / block_commitment.go
1 package types
2
3 import (
4         "io"
5
6         "github.com/vapor/encoding/blockchain"
7         "github.com/vapor/protocol/bc"
8 )
9
10 // BlockCommitment store the TransactionsMerkleRoot && TransactionStatusHash
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         // TransactionStatusHash is the root hash of the Merkle binary hash tree
17         // formed by the hashes of all transaction verify results
18         TransactionStatusHash bc.Hash `json:"transaction_status_hash"`
19 }
20
21 func (bc *BlockCommitment) readFrom(r *blockchain.Reader) error {
22         if _, err := bc.TransactionsMerkleRoot.ReadFrom(r); err != nil {
23                 return err
24         }
25
26         _, err := bc.TransactionStatusHash.ReadFrom(r)
27         return err
28 }
29
30 func (bc *BlockCommitment) writeTo(w io.Writer) error {
31         if _, err := bc.TransactionsMerkleRoot.WriteTo(w); err != nil {
32                 return err
33         }
34
35         _, err := bc.TransactionStatusHash.WriteTo(w)
36         return err
37 }