Conform to go-wire 1.0

This commit is contained in:
Jae Kwon
2015-11-10 13:10:43 -08:00
parent 37b6255e42
commit d69b5c5ab6
15 changed files with 63 additions and 60 deletions
+2
View File
@@ -12,6 +12,8 @@ import (
"github.com/tendermint/go-wire"
)
const MaxBlockSize = 22020096 // 21MB TODO make it configurable
type Block struct {
*Header `json:"header"`
*Data `json:"data"`
+2 -2
View File
@@ -9,9 +9,9 @@ import (
"code.google.com/p/go.crypto/ripemd160"
"github.com/tendermint/go-wire"
. "github.com/tendermint/go-common"
"github.com/tendermint/go-merkle"
"github.com/tendermint/go-wire"
)
const (
@@ -75,7 +75,7 @@ func (psh PartSetHeader) Equals(other PartSetHeader) bool {
return psh.Total == other.Total && bytes.Equal(psh.Hash, other.Hash)
}
func (psh PartSetHeader) WriteSignBytes(w io.Writer, n *int64, err *error) {
func (psh PartSetHeader) WriteSignBytes(w io.Writer, n *int, err *error) {
wire.WriteTo([]byte(Fmt(`{"hash":"%X","total":%v}`, psh.Hash, psh.Total)), w, n, err)
}
+1 -1
View File
@@ -37,7 +37,7 @@ func (p *Proposal) String() string {
p.BlockPartsHeader, p.POLRound, p.Signature)
}
func (p *Proposal) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error) {
func (p *Proposal) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) {
wire.WriteTo([]byte(Fmt(`{"chain_id":"%s"`, chainID)), w, n, err)
wire.WriteTo([]byte(`,"proposal":{"block_parts_header":`), w, n, err)
p.BlockPartsHeader.WriteSignBytes(w, n, err)
+2 -2
View File
@@ -11,12 +11,12 @@ import (
// Signable is an interface for all signable things.
// It typically removes signatures before serializing.
type Signable interface {
WriteSignBytes(chainID string, w io.Writer, n *int64, err *error)
WriteSignBytes(chainID string, w io.Writer, n *int, err *error)
}
// SignBytes is a convenience method for getting the bytes to sign of a Signable.
func SignBytes(chainID string, o Signable) []byte {
buf, n, err := new(bytes.Buffer), new(int64), new(error)
buf, n, err := new(bytes.Buffer), new(int), new(error)
o.WriteSignBytes(chainID, buf, n, err)
if *err != nil {
PanicCrisis(err)
+3 -3
View File
@@ -71,12 +71,12 @@ var ValidatorCodec = validatorCodec{}
type validatorCodec struct{}
func (vc validatorCodec) Encode(o interface{}, w io.Writer, n *int64, err *error) {
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 *int64, err *error) interface{} {
return wire.ReadBinary(&Validator{}, r, 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 {
+7 -7
View File
@@ -5,8 +5,8 @@ import (
"fmt"
"io"
"github.com/tendermint/go-crypto"
. "github.com/tendermint/go-common"
"github.com/tendermint/go-crypto"
"github.com/tendermint/go-wire"
)
@@ -28,11 +28,11 @@ func (err *ErrVoteConflictingSignature) Error() string {
// Represents a prevote, precommit, or commit vote from validators for consensus.
type Vote struct {
Height int `json:"height"`
Round int `json:"round"`
Type byte `json:"type"`
BlockHash []byte `json:"block_hash"` // empty if vote is nil.
BlockPartsHeader PartSetHeader `json:"block_parts_header"` // zero if vote is nil.
Height int `json:"height"`
Round int `json:"round"`
Type byte `json:"type"`
BlockHash []byte `json:"block_hash"` // empty if vote is nil.
BlockPartsHeader PartSetHeader `json:"block_parts_header"` // zero if vote is nil.
Signature crypto.SignatureEd25519 `json:"signature"`
}
@@ -42,7 +42,7 @@ const (
VoteTypePrecommit = byte(0x02)
)
func (vote *Vote) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error) {
func (vote *Vote) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) {
wire.WriteTo([]byte(Fmt(`{"chain_id":"%s"`, chainID)), w, n, err)
wire.WriteTo([]byte(Fmt(`,"vote":{"block_hash":"%X","block_parts_header":%v`, vote.BlockHash, vote.BlockPartsHeader)), w, n, err)
wire.WriteTo([]byte(Fmt(`,"height":%v,"round":%v,"type":%v}}`, vote.Height, vote.Round, vote.Type)), w, n, err)