Initial pass at bft_fix_2 completion

This commit is contained in:
Jae Kwon
2016-09-05 17:33:02 -07:00
committed by Ethan Buchman
parent 655d829314
commit b73a6905a1
5 changed files with 339 additions and 71 deletions

View File

@ -27,6 +27,24 @@ func (err *ErrVoteConflictingVotes) Error() string {
return "Conflicting votes"
}
// Types of votes
// TODO Make a new type "VoteType"
const (
VoteTypePrevote = byte(0x01)
VoteTypePrecommit = byte(0x02)
)
func IsVoteTypeValid(type_ byte) bool {
switch type_ {
case VoteTypePrevote:
return true
case VoteTypePrecommit:
return true
default:
return false
}
}
// Represents a prevote, precommit, or commit vote from validators for consensus.
type Vote struct {
ValidatorAddress []byte `json:"validator_address"`
@ -38,12 +56,6 @@ type Vote struct {
Signature crypto.SignatureEd25519 `json:"signature"`
}
// Types of votes
const (
VoteTypePrevote = byte(0x01)
VoteTypePrecommit = byte(0x02)
)
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)