mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-12 23:01:30 +00:00
handle panics
This commit is contained in:
@@ -948,6 +948,8 @@ func (cs *State) receiveRoutine(ctx context.Context, maxSteps int) {
|
||||
|
||||
// state transitions on complete-proposal, 2/3-any, 2/3-one
|
||||
func (cs *State) handleMsg(ctx context.Context, mi msgInfo) {
|
||||
cs.mtx.Lock()
|
||||
defer cs.mtx.Unlock()
|
||||
var (
|
||||
added bool
|
||||
err error
|
||||
@@ -959,13 +961,10 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo) {
|
||||
case *ProposalMessage:
|
||||
// will not cause transition.
|
||||
// once proposal is set, we can receive block parts
|
||||
cs.mtx.Lock()
|
||||
err = cs.setProposal(msg.Proposal, mi.ReceiveTime)
|
||||
cs.mtx.Unlock()
|
||||
|
||||
case *BlockPartMessage:
|
||||
// if the proposal is complete, we'll enterPrevote or tryFinalizeCommit
|
||||
cs.mtx.Lock()
|
||||
added, err = cs.addProposalBlockPart(ctx, msg, peerID)
|
||||
|
||||
// We unlock here to yield to any routines that need to read the the RoundState.
|
||||
@@ -989,7 +988,6 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo) {
|
||||
select {
|
||||
case cs.statsMsgQueue <- mi:
|
||||
case <-ctx.Done():
|
||||
cs.mtx.Unlock()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -1003,22 +1001,18 @@ func (cs *State) handleMsg(ctx context.Context, mi msgInfo) {
|
||||
)
|
||||
err = nil
|
||||
}
|
||||
cs.mtx.Unlock()
|
||||
|
||||
case *VoteMessage:
|
||||
// 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
|
||||
cs.mtx.Lock()
|
||||
added, err = cs.tryAddVote(ctx, msg.Vote, peerID)
|
||||
if added {
|
||||
select {
|
||||
case cs.statsMsgQueue <- mi:
|
||||
case <-ctx.Done():
|
||||
cs.mtx.Unlock()
|
||||
return
|
||||
}
|
||||
}
|
||||
cs.mtx.Unlock()
|
||||
|
||||
// TODO: punish peer
|
||||
// We probably don't want to stop the peer here. The vote does not
|
||||
|
||||
Reference in New Issue
Block a user