OSDN Git Service

rename create-account-address command (#432)
[bytom/bytom.git] / protocol / bc / legacy / block_commitment.go
1 package legacy
2
3 import (
4         "io"
5
6         "github.com/bytom/encoding/blockchain"
7         "github.com/bytom/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
13         // tree formed by the hashes of all transactions included in the
14         // block.
15         TransactionsMerkleRoot bc.Hash `json:"transaction_merkle_root"`
16
17         // TransactionStatusHash is the hash of transaction status bitmap
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         _, err := bc.TransactionStatusHash.ReadFrom(r)
26         return err
27 }
28
29 func (bc *BlockCommitment) writeTo(w io.Writer) error {
30         _, err := bc.TransactionsMerkleRoot.WriteTo(w)
31         if err != nil {
32                 return err
33         }
34         _, err = bc.TransactionStatusHash.WriteTo(w)
35         if err != nil {
36                 return err
37         }
38         return err
39 }