From 5e015bc669a054c206407302bb33ea8ba0a4c3ec Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Thu, 10 Sep 2015 01:29:49 -0700 Subject: [PATCH] Probable fix for #140 --- consensus/reactor.go | 18 +++++++++++++----- types/vote_set.go | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index e822cbfb2..4605c7bb7 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -553,19 +553,19 @@ OUTER_LOOP: // Read only when returned by PeerState.GetRoundState(). type PeerRoundState struct { Height int // Height peer is at - Round int // Round peer is at + Round int // Round peer is at, -1 if unknown. 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 ProposalBlockPartsHeader types.PartSetHeader // ProposalBlockParts *BitArray // - ProposalPOLRound int // -1 if none + ProposalPOLRound int // Proposal's POL round. -1 if none. ProposalPOL *BitArray // nil until ProposalPOLMessage received. Prevotes *BitArray // All votes peer has for this round Precommits *BitArray // All precommits peer has for this round - LastCommitRound int // Round of commit for last height. + LastCommitRound int // Round of commit for last height. -1 if none. LastCommit *BitArray // All commit precommits of commit for last height. - CatchupCommitRound int // Round that we believe commit round is. + CatchupCommitRound int // Round that we believe commit round is. -1 if none. CatchupCommit *BitArray // All commit precommits peer has for this height } @@ -584,7 +584,15 @@ type PeerState struct { } func NewPeerState(peer *p2p.Peer) *PeerState { - return &PeerState{Peer: peer} + return &PeerState{ + Peer: peer, + PeerRoundState: PeerRoundState{ + Round: -1, + ProposalPOLRound: -1, + LastCommitRound: -1, + CatchupCommitRound: -1, + }, + } } // Returns an atomic snapshot of the PeerRoundState. diff --git a/types/vote_set.go b/types/vote_set.go index cba34eef1..23a69892d 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -59,7 +59,7 @@ func (voteSet *VoteSet) Height() int { func (voteSet *VoteSet) Round() int { if voteSet == nil { - return 0 + return -1 } else { return voteSet.round }