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

@ -3,10 +3,8 @@ package types
import (
"bytes"
"fmt"
"io"
"github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire"
cmn "github.com/tendermint/tmlibs/common"
)
@ -14,9 +12,9 @@ import (
// NOTE: The Accum is not included in Validator.Hash();
// make sure to update that method if changes are made here
type Validator struct {
Address Address `json:"address"`
PubKey crypto.PubKey `json:"pub_key"`
VotingPower int64 `json:"voting_power"`
Address Address `json:"address"`
PubKey crypto.PubKey `json:"pub_key"`
VotingPower int64 `json:"voting_power"`
Accum int64 `json:"accum"`
}
@ -72,7 +70,7 @@ func (v *Validator) String() string {
// Hash computes the unique ID of a validator with a given voting power.
// It excludes the Accum value, which changes with every round.
func (v *Validator) Hash() []byte {
return wire.BinaryRipemd160(struct {
return tmHash(struct {
Address Address
PubKey crypto.PubKey
VotingPower int64
@ -83,25 +81,6 @@ func (v *Validator) Hash() []byte {
})
}
//-------------------------------------
var ValidatorCodec = validatorCodec{}
type validatorCodec struct{}
func (vc validatorCodec) Encode(o interface{}, w io.Writer, n *int, err *error) {
wire.WriteBinary(o.(*Validator), w, n, err)
}
func (vc validatorCodec) Decode(r io.Reader, n *int, err *error) interface{} {
return wire.ReadBinary(&Validator{}, r, 0, n, err)
}
func (vc validatorCodec) Compare(o1 interface{}, o2 interface{}) int {
cmn.PanicSanity("ValidatorCodec.Compare not implemented")
return 0
}
//--------------------------------------------------------------------------------
// For testing...