|
@ -862,6 +862,8 @@ func (cs *State) receiveRoutine(maxSteps int) { |
|
|
|
|
|
|
|
|
// state transitions on complete-proposal, 2/3-any, 2/3-one
|
|
|
// state transitions on complete-proposal, 2/3-any, 2/3-one
|
|
|
func (cs *State) handleMsg(mi msgInfo) { |
|
|
func (cs *State) handleMsg(mi msgInfo) { |
|
|
|
|
|
cs.mtx.Lock() |
|
|
|
|
|
defer cs.mtx.Unlock() |
|
|
var ( |
|
|
var ( |
|
|
added bool |
|
|
added bool |
|
|
err error |
|
|
err error |
|
@ -873,13 +875,10 @@ func (cs *State) handleMsg(mi msgInfo) { |
|
|
case *ProposalMessage: |
|
|
case *ProposalMessage: |
|
|
// will not cause transition.
|
|
|
// will not cause transition.
|
|
|
// once proposal is set, we can receive block parts
|
|
|
// once proposal is set, we can receive block parts
|
|
|
cs.mtx.Lock() |
|
|
|
|
|
err = cs.setProposal(msg.Proposal) |
|
|
err = cs.setProposal(msg.Proposal) |
|
|
cs.mtx.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
case *BlockPartMessage: |
|
|
case *BlockPartMessage: |
|
|
// if the proposal is complete, we'll enterPrevote or tryFinalizeCommit
|
|
|
// if the proposal is complete, we'll enterPrevote or tryFinalizeCommit
|
|
|
cs.mtx.Lock() |
|
|
|
|
|
added, err = cs.addProposalBlockPart(msg, peerID) |
|
|
added, err = cs.addProposalBlockPart(msg, peerID) |
|
|
|
|
|
|
|
|
// We unlock here to yield to any routines that need to read the the RoundState.
|
|
|
// We unlock here to yield to any routines that need to read the the RoundState.
|
|
@ -912,17 +911,14 @@ func (cs *State) handleMsg(mi msgInfo) { |
|
|
) |
|
|
) |
|
|
err = nil |
|
|
err = nil |
|
|
} |
|
|
} |
|
|
cs.mtx.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
case *VoteMessage: |
|
|
case *VoteMessage: |
|
|
// attempt to add the vote and dupeout the validator if its a duplicate signature
|
|
|
// attempt to add the vote and dupeout the validator if its a duplicate signature
|
|
|
// if the vote gives us a 2/3-any or 2/3-one, we transition
|
|
|
// if the vote gives us a 2/3-any or 2/3-one, we transition
|
|
|
cs.mtx.Lock() |
|
|
|
|
|
added, err = cs.tryAddVote(msg.Vote, peerID) |
|
|
added, err = cs.tryAddVote(msg.Vote, peerID) |
|
|
if added { |
|
|
if added { |
|
|
cs.statsMsgQueue <- mi |
|
|
cs.statsMsgQueue <- mi |
|
|
} |
|
|
} |
|
|
cs.mtx.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
// if err == ErrAddingVote {
|
|
|
// if err == ErrAddingVote {
|
|
|
// TODO: punish peer
|
|
|
// TODO: punish peer
|
|
|