func (pv *PrivValidator) GetLastSignature() crypto.Signature {
	return pv.LastSignature.Signature
}
func (pv *PrivValidator) CoinbaseKey() crypto.PubKey {
return pv.Coinbase.PubKey
}
package types
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"sync"
	pbtypes "github.com/annchain/annchain/angine/protos/types"
	"github.com/annchain/annchain/module/lib/ed25519"
	. "github.com/annchain/annchain/module/lib/go-common"
	"github.com/annchain/annchain/module/lib/go-crypto"
	"github.com/annchain/annchain/module/xlib/def"
	"go.uber.org/zap"
)
const (
	stepNone      = 0  
	stepPropose   = 1
	stepPrevote   = 2
	stepPrecommit = 3
)
func voteToStep(vote *pbtypes.Vote) int8 {
	switch vote.Data.Type {
	case pbtypes.VoteType_Prevote:
		return stepPrevote
	case pbtypes.VoteType_Precommit:
		return stepPrecommit
	default:
		PanicSanity("Unknown vote type")
		return 0
	}
}
type PrivValidatorJSON struct {
	PubKey        crypto.StPubKey    `json:"pub_key"`
	Coinbase      Bytes              `json:"coin_base"`
	LastHeight    def.INT            `json:"last_height"`
	LastRound     def.INT            `json:"last_round"`
	LastStep      int8               `json:"last_step"`
	LastSignature crypto.StSignature `json:"last_signature"`  
	LastSignBytes Bytes              `json:"last_signbytes"`  
	PrivKey crypto.StPrivKey `json:"priv_key"`
}
type PrivValidator struct {
	PrivValidatorJSON
	Signer `json:"-"`
	address Bytes
	filePath string
	mtx      sync.Mutex
	logger *zap.Logger
}
func (pv *PrivValidator) CopyReset() (cp PrivValidator) {
	cp.PubKey = pv.PubKey
	cp.Coinbase = pv.Coinbase
	cp.PrivKey = pv.PrivKey
	cp.Signer = NewDefaultSigner(pv.GetPrivKey())
	return
}
func (pv *PrivValidator) GetPubKey() crypto.PubKey {
	return pv.PubKey.PubKey
}