Add Network to SignBytes, to prevent network clashes

This commit is contained in:
Jae Kwon
2015-04-20 23:59:52 -07:00
parent 733dfcf4ad
commit 2ba6f86f2e
9 changed files with 51 additions and 40 deletions
+2 -2
View File
@@ -545,7 +545,7 @@ OUTER_LOOP:
type PeerRoundState struct {
Height uint // Height peer is at
Round uint // Round peer is at
Step RoundStep // Step peer is at
Step RoundStepType // Step peer is at
StartTime time.Time // Estimated start of round 0 at this height
Proposal bool // True if peer has proposal for this round
ProposalBlockParts types.PartSetHeader //
@@ -790,7 +790,7 @@ func DecodeMessage(bz []byte) (msgType byte, msg ConsensusMessage, err error) {
type NewRoundStepMessage struct {
Height uint
Round uint
Step RoundStep
Step RoundStepType
SecondsSinceStartTime uint
}
+17 -17
View File
@@ -88,20 +88,20 @@ var (
)
//-----------------------------------------------------------------------------
// RoundStep enum type
// RoundStepType enum type
type RoundStep uint8
type RoundStepType uint8 // These must be numeric, ordered.
const (
RoundStepNewHeight = RoundStep(0x00) // Round0 for new height started, wait til CommitTime + Delta
RoundStepNewRound = RoundStep(0x01) // Pseudostep, immediately goes to RoundStepPropose
RoundStepPropose = RoundStep(0x10) // Did propose, gossip proposal
RoundStepPrevote = RoundStep(0x11) // Did prevote, gossip prevotes
RoundStepPrecommit = RoundStep(0x12) // Did precommit, gossip precommits
RoundStepCommit = RoundStep(0x20) // Entered commit state machine
RoundStepNewHeight = RoundStepType(0x01) // Round0 for new height started, wait til CommitTime + Delta
RoundStepNewRound = RoundStepType(0x02) // Pseudostep, immediately goes to RoundStepPropose
RoundStepPropose = RoundStepType(0x03) // Did propose, gossip proposal
RoundStepPrevote = RoundStepType(0x04) // Did prevote, gossip prevotes
RoundStepPrecommit = RoundStepType(0x05) // Did precommit, gossip precommits
RoundStepCommit = RoundStepType(0x06) // Entered commit state machine
)
func (rs RoundStep) String() string {
func (rs RoundStepType) String() string {
switch rs {
case RoundStepNewHeight:
return "RoundStepNewHeight"
@@ -123,15 +123,15 @@ func (rs RoundStep) String() string {
//-----------------------------------------------------------------------------
// RoundAction enum type
type RoundActionType uint8
type RoundActionType string
const (
RoundActionPropose = RoundActionType(0xA0) // Propose and goto RoundStepPropose
RoundActionPrevote = RoundActionType(0xA1) // Prevote and goto RoundStepPrevote
RoundActionPrecommit = RoundActionType(0xA2) // Precommit and goto RoundStepPrecommit
RoundActionTryCommit = RoundActionType(0xC0) // Goto RoundStepCommit, or RoundStepPropose for next round.
RoundActionCommit = RoundActionType(0xC1) // Goto RoundStepCommit upon +2/3 commits
RoundActionTryFinalize = RoundActionType(0xC2) // Maybe goto RoundStepPropose for next round.
RoundActionPropose = RoundActionType("PR") // Propose and goto RoundStepPropose
RoundActionPrevote = RoundActionType("PV") // Prevote and goto RoundStepPrevote
RoundActionPrecommit = RoundActionType("PC") // Precommit and goto RoundStepPrecommit
RoundActionTryCommit = RoundActionType("TC") // Goto RoundStepCommit, or RoundStepPropose for next round.
RoundActionCommit = RoundActionType("CM") // Goto RoundStepCommit upon +2/3 commits
RoundActionTryFinalize = RoundActionType("TF") // Maybe goto RoundStepPropose for next round.
)
func (rat RoundActionType) String() string {
@@ -171,7 +171,7 @@ func (ra RoundAction) String() string {
type RoundState struct {
Height uint // Height we are working on
Round uint
Step RoundStep
Step RoundStepType
StartTime time.Time
CommitTime time.Time // Time when +2/3 commits were found
Validators *sm.ValidatorSet
+1 -1
View File
@@ -82,7 +82,7 @@ func TestRunActionPropose(t *testing.T) {
}
func checkRoundState(t *testing.T, rs *RoundState,
height uint, round uint, step RoundStep) {
height uint, round uint, step RoundStepType) {
if rs.Height != height {
t.Errorf("rs.Height should be %v, got %v", height, rs.Height)
}
+2
View File
@@ -7,6 +7,7 @@ import (
"github.com/tendermint/tendermint/account"
"github.com/tendermint/tendermint/binary"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/types"
)
@@ -38,6 +39,7 @@ 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)