OSDN Git Service

feat: add processIssuing (#152)
[bytom/vapor.git] / vendor / github.com / bytom / protocol / bc / types / block_commitment.go
diff --git a/vendor/github.com/bytom/protocol/bc/types/block_commitment.go b/vendor/github.com/bytom/protocol/bc/types/block_commitment.go
new file mode 100644 (file)
index 0000000..ad4d822
--- /dev/null
@@ -0,0 +1,37 @@
+package types
+
+import (
+       "io"
+
+       "github.com/bytom/encoding/blockchain"
+       "github.com/bytom/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
+}