-
Notifications
You must be signed in to change notification settings - Fork 9
/
block_commitment.go
37 lines (29 loc) · 1.02 KB
/
block_commitment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package types
import (
"io"
"github.com/bytom/vapor/encoding/blockchain"
"github.com/bytom/vapor/protocol/bc"
)
// BlockCommitment store the TransactionsMerkleRoot && TransactionStatusHash
type BlockCommitment struct {
// TransactionsMerkleRoot is the root hash of the Merkle binary hash tree
// formed by the hashes of all transactions included in the block.
TransactionsMerkleRoot bc.Hash `json:"transaction_merkle_root"`
// TransactionStatusHash is the root hash of the Merkle binary hash tree
// formed by the hashes of all transaction verify results
TransactionStatusHash bc.Hash `json:"transaction_status_hash"`
}
func (bc *BlockCommitment) readFrom(r *blockchain.Reader) error {
if _, err := bc.TransactionsMerkleRoot.ReadFrom(r); err != nil {
return err
}
_, err := bc.TransactionStatusHash.ReadFrom(r)
return err
}
func (bc *BlockCommitment) writeTo(w io.Writer) error {
if _, err := bc.TransactionsMerkleRoot.WriteTo(w); err != nil {
return err
}
_, err := bc.TransactionStatusHash.WriteTo(w)
return err
}