func (r *Request) Sign(signer *asymmetric.PrivateKey) (err error) {
	r.Header.BatchCount = uint64(len(r.Payload.Queries))
	if err = buildHash(&r.Payload, &r.Header.QueriesHash); err != nil {
		return
	}
	return r.Header.Sign(signer)
}
Sign the request.
package types
import (
	"fmt"
	"time"
	"github.com/SQLess/SQLess/crypto/asymmetric"
	"github.com/SQLess/SQLess/crypto/hash"
	"github.com/SQLess/SQLess/crypto/verifier"
	"github.com/SQLess/SQLess/proto"
)
type QueryType int32
const (
	ReadQuery QueryType = iota
	WriteQuery
	NumberOfQueryType
)
type NamedArg struct {
	Name  string
	Value interface{}
}
type Query struct {
	Pattern string
	Args    []NamedArg
}
type RequestPayload struct {
	Queries []Query `json:"qs"`
}
type RequestHeader struct {
	QueryType    QueryType        `json:"qt"`
	NodeID       proto.NodeID     `json:"id"`    
	DatabaseID   proto.DatabaseID `json:"dbid"`  
	ConnectionID uint64           `json:"cid"`
	SeqNo        uint64           `json:"seq"`
	Timestamp    time.Time        `json:"t"`   
	BatchCount   uint64           `json:"bc"`  
	QueriesHash  hash.Hash        `json:"qh"`  
}
func (h *RequestHeader) GetQueryKey() QueryKey {
	return QueryKey{
		NodeID:       h.NodeID,
		ConnectionID: h.ConnectionID,
		SeqNo:        h.SeqNo,
	}
}
type QueryKey struct {
	NodeID       proto.NodeID `json:"id"`
	ConnectionID uint64       `json:"cid"`
	SeqNo        uint64       `json:"seq"`
}
func (k QueryKey) String() string {
	return fmt.Sprintf("%s#%016x#%016x", string(k.NodeID[len(k.NodeID)-8:]), k.ConnectionID, k.SeqNo)
}
type SignedRequestHeader struct {
	RequestHeader
	verifier.DefaultHashSignVerifierImpl
}
type Request struct {
	proto.Envelope
	Header        SignedRequestHeader `json:"h"`
	Payload       RequestPayload      `json:"p"`
	_marshalCache []byte              `json:"-"`
}
func (t QueryType) String() string {
	switch t {
	case ReadQuery:
		return "read"
	case WriteQuery:
		return "write"
	default:
		return "unknown"
	}
}
func (sh *SignedRequestHeader) Verify() (err error) {
	return sh.DefaultHashSignVerifierImpl.Verify(&sh.RequestHeader)
}
func (sh *SignedRequestHeader) Sign(signer *asymmetric.PrivateKey) (err error) {
	return sh.DefaultHashSignVerifierImpl.Sign(&sh.RequestHeader, signer)
}
func (r *Request) Verify() (err error) {
	if err = verifyHash(&r.Payload, &r.Header.QueriesHash); err != nil {
		return
	}
	return r.Header.Verify()
}