types: update for new go-wire. WriteSignBytes -> SignBytes

This commit is contained in:
Ethan Buchman
2018-01-14 19:05:22 -05:00
parent 9cdba04fe9
commit 200787ede2
12 changed files with 67 additions and 81 deletions

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"io"
"time"
"github.com/tendermint/go-crypto"
@@ -73,11 +72,15 @@ type Vote struct {
Signature crypto.Signature `json:"signature"`
}
func (vote *Vote) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) {
wire.WriteJSON(CanonicalJSONOnceVote{
func (vote *Vote) SignBytes(chainID string) []byte {
bz, err := wire.MarshalJSON(CanonicalJSONOnceVote{
chainID,
CanonicalVote(vote),
}, w, n, err)
})
if err != nil {
panic(err)
}
return bz
}
func (vote *Vote) Copy() *Vote {
@@ -111,7 +114,7 @@ func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error {
return ErrVoteInvalidValidatorAddress
}
if !pubKey.VerifyBytes(SignBytes(chainID, vote), vote.Signature) {
if !pubKey.VerifyBytes(vote.SignBytes(chainID), vote.Signature) {
return ErrVoteInvalidSignature
}
return nil