func (b *BPBlock) VerifyHash() error {
	if err := b.verifyMerkleRoot(); err != nil {
		return err
	}
	return b.SignedHeader.verifyHash()
}
VerifyHash verifies the block header hash, including the merkle root of the packed transactions.
package types
import (
	"time"
	pi "github.com/SQLess/SQLess/blockproducer/interfaces"
	"github.com/SQLess/SQLess/crypto/asymmetric"
	"github.com/SQLess/SQLess/crypto/hash"
	"github.com/SQLess/SQLess/crypto/verifier"
	"github.com/SQLess/SQLess/merkle"
	"github.com/SQLess/SQLess/proto"
)
type BPHeader struct {
	Version    int32
	Producer   proto.AccountAddress
	MerkleRoot hash.Hash
	ParentHash hash.Hash
	Timestamp  time.Time
}
type BPSignedHeader struct {
	BPHeader
	verifier.DefaultHashSignVerifierImpl
}
func (s *BPSignedHeader) verifyHash() error {
	return s.DefaultHashSignVerifierImpl.VerifyHash(&s.BPHeader)
}
func (s *BPSignedHeader) verify() error {
	return s.DefaultHashSignVerifierImpl.Verify(&s.BPHeader)
}
func (s *BPSignedHeader) setHash() error {
	return s.DefaultHashSignVerifierImpl.SetHash(&s.BPHeader)
}
func (s *BPSignedHeader) sign(signer *asymmetric.PrivateKey) error {
	return s.DefaultHashSignVerifierImpl.Sign(&s.BPHeader, signer)
}
type BPBlock struct {
	SignedHeader BPSignedHeader
	Transactions []pi.Transaction
}
func (b *BPBlock) GetTxHashes() []*hash.Hash {
	hs := make([]*hash.Hash, len(b.Transactions))
	for i, v := range b.Transactions {
		h := v.Hash()
		hs[i] = &h
	}
	return hs
}
func (b *BPBlock) setMerkleRoot() {
	var merkleRoot = merkle.NewMerkle(b.GetTxHashes()).GetRoot()
	b.SignedHeader.MerkleRoot = *merkleRoot
}
func (b *BPBlock) verifyMerkleRoot() error {
	var merkleRoot = *merkle.NewMerkle(b.GetTxHashes()).GetRoot()
	if !merkleRoot.IsEqual(&b.SignedHeader.MerkleRoot) {
		return ErrMerkleRootVerification
	}
	return nil
}
func (b *BPBlock) SetHash() error {
	b.setMerkleRoot()
	return b.SignedHeader.setHash()
}