diff --git a/types/part_set.go b/types/part_set.go index f132c5fe6..ade421450 100644 --- a/types/part_set.go +++ b/types/part_set.go @@ -74,7 +74,15 @@ func (psh PartSetHeader) Equals(other PartSetHeader) bool { } 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) + wire.WriteJSON( + struct { + Hash []byte `json:"hash"` + Total int `json:"total"` + }{ + psh.Hash, + psh.Total, + }, + w, n, err) } //------------------------------------- diff --git a/types/proposal.go b/types/proposal.go index 85ac5f061..91e53038f 100644 --- a/types/proposal.go +++ b/types/proposal.go @@ -5,7 +5,7 @@ import ( "fmt" "io" - . "github.com/tendermint/go-common" + //. "github.com/tendermint/go-common" "github.com/tendermint/go-crypto" "github.com/tendermint/go-wire" ) @@ -16,12 +16,12 @@ var ( ) type Proposal struct { - Height int `json:"height"` - Round int `json:"round"` - BlockPartsHeader PartSetHeader `json:"block_parts_header"` - POLRound int `json:"pol_round"` // -1 if null. - POLBlockID BlockID `json:"pol_block_id"` // zero if null. - Signature crypto.SignatureEd25519 `json:"signature"` + Height int `json:"height"` + Round int `json:"round"` + BlockPartsHeader PartSetHeader `json:"block_parts_header"` + POLRound int `json:"pol_round"` // -1 if null. + POLBlockID BlockID `json:"pol_block_id"` // zero if null. + Signature crypto.Signature `json:"signature"` } // polRound: -1 if no polRound. @@ -41,11 +41,32 @@ func (p *Proposal) String() string { } 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) - wire.WriteTo([]byte(Fmt(`,"height":%v,"pol_block_id":`, p.Height)), w, n, err) - p.POLBlockID.WriteSignBytes(w, n, err) - wire.WriteTo([]byte(Fmt(`,"pol_round":%v`, p.POLRound)), w, n, err) - wire.WriteTo([]byte(Fmt(`,"round":%v}}`, p.Round)), w, n, err) + + wire.WriteJSON( + struct { + ChainID string `json:"chain_id"` + Proposal struct { + BlockPartsHeader PartSetHeader `json:"block_parts_header"` + Height int `json:"height"` + POLBlockID BlockID `json:"pol_block_id"` + POLRound int `json:"pol_round"` + Round int `json:"round"` + } `json:"proposal"` + }{ + chainID, + struct { + BlockPartsHeader PartSetHeader `json:"block_parts_header"` + Height int `json:"height"` + POLBlockID BlockID `json:"pol_block_id"` + POLRound int `json:"pol_round"` + Round int `json:"round"` + }{ + p.BlockPartsHeader, + p.Height, + p.POLBlockID, + p.POLRound, + p.Round, + }, + }, + w, n, err) } diff --git a/types/vote.go b/types/vote.go index 92d99f485..e95008639 100644 --- a/types/vote.go +++ b/types/vote.go @@ -57,10 +57,40 @@ type Vote struct { } 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(`,"vote":{"block_id":`), w, n, err) - vote.BlockID.WriteSignBytes(w, n, err) - wire.WriteTo([]byte(Fmt(`,"height":%v,"round":%v,"type":%v}}`, vote.Height, vote.Round, vote.Type)), w, n, err) + + wire.WriteJSON( + struct { + ChainID string `json:"chain_id"` + Vote struct { + BlockID BlockID `json:"block_id"` + Height int `json:"height"` + Round int `json:"round"` + Signature crypto.Signature `json:"signature"` + Type byte `json:"type"` + ValidatorAddress []byte `json:"validator_address"` + ValidatorIndex int `json:"validator_index"` + } `json: "vote"` + }{ + chainID, + struct { + BlockID BlockID `json:"block_id"` + Height int `json:"height"` + Round int `json:"round"` + Signature crypto.Signature `json:"signature"` + Type byte `json:"type"` + ValidatorAddress []byte `json:"validator_address"` + ValidatorIndex int `json:"validator_index"` + }{ + vote.BlockID, + vote.Height, + vote.Round, + vote.Signature, + vote.Type, + vote.ValidatorAddress, + vote.ValidatorIndex, + }, + }, + w, n, err) } func (vote *Vote) Copy() *Vote {