mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-18 22:14:35 +00:00
Conform to go-wire 1.0
This commit is contained in:
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user