Proposal WriteSignBytes is JSON

This commit is contained in:
Jae Kwon
2015-04-27 20:55:28 -07:00
parent 0cb99be988
commit 5366d808ba
3 changed files with 40 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/tendermint/tendermint/account"
"github.com/tendermint/tendermint/binary"
. "github.com/tendermint/tendermint/common"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/types"
)
@@ -39,9 +40,11 @@ func (p *Proposal) String() string {
}
func (p *Proposal) WriteSignBytes(w io.Writer, n *int64, err *error) {
binary.WriteString(config.App().GetString("Network"), w, n, err)
binary.WriteUvarint(p.Height, w, n, err)
binary.WriteUvarint(p.Round, w, n, err)
binary.WriteBinary(p.BlockParts, w, n, err)
binary.WriteBinary(p.POLParts, w, n, err)
// We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"Network":"%X"`, config.App().GetString("Network"))), w, n, err)
binary.WriteTo([]byte(`,"Proprosal":{"BlockParts":`), w, n, err)
p.BlockParts.WriteSignBytes(w, n, err)
binary.WriteTo([]byte(Fmt(`,"Height":%v,"POLParts":`, p.Height)), w, n, err)
p.POLParts.WriteSignBytes(w, n, err)
binary.WriteTo([]byte(Fmt(`,"Round":%v}}`, p.Round)), w, n, err)
}