메시지를 받을 때마다
handlemsg 함수 안에서 호출되어 (여러 depth를 거침) 실행된다.dir : consensus/state.go
네트워크 딜레이 등으로 인한 이전 블럭에 대한 precommit이 들어왔을 경우 이전 블럭에 관한 정보를 업데이트 해주고 publish
if vote.Height + 1 == cs.Height && vote.Type == tmproto.PrecommitType {
//
if cs.Step != cstypes.RoundStepNewHeight {
return
}
// ...
// LastCommit : last precommits at (height - 1)
added, err := cs.LastCommit.AddVote(vote)
if !added { return }
// ... logging, broadcasting
// timeout skip이 가능하게 설정했고, vote를 전부 모았다면
// 바로 cs.Height의 다음 round 진입
if cs.config.SkipTimeoutCommit && cs.LastCommit.HasAll() {
cs.enterNewRound(cs.Height, 0)
}
return
}
문제가 없는 vote라면 추가
height := cs.Height
// 중복 등의 이유로 vote가 추가되지 않았다면 리턴
added, err := cs.Votes.AddVote(vote, peerID)
if !added { return }
// ... evt publish, FireEvent
vote type에 따라 다른 코드 실행 (type == Prevote || PreCommit)