dir : consensus/state.go
msg의 type 확인
msg, peerID := mi.Msg, mi.PeerID
switch msg := msg.(type) {
// Proposal msg인 경우 (defaultDecideProposal())
case *ProposalMessage:
// proposal을 set - cs의 proposal attribute의 value를 설정한다.
// 이후 block parts들을 수신할 수 있음.
// cs.setProposal은 cs 인스턴스 생성시 defaultSetProposal 함수를 대입했음
err = cs.setProposal(msg.Proposal)
// block parts들을 받았을 경우 (proposal or commit step에서 주로 실행)
case *BlockPartMessage:
// proposal이 완료되었다면 enterprevote 혹은 tryFinalizeCommit 함수를 실행한다.
// block parts들을 수신해 추가
// 추가되었다면 added는 true, vice versa
added, err = cs.addProposalBlockPart(msg, peerID)
// block parts들을 다 받았다면 Proposal 처리 시작
if added && cs.ProposalBlockparts.IsComplete() {
cs.handleCompleteProposal(msg.Height)
}
// block parts 추가에 성공했다면 메시지 송신
if added {
cs.statsMsgQueue <- mi
}
// Vote message의 경우
// signAddVote() 함수에서 송신한 메시지에 반응한다.
case *VoteMessage:
// vote 인스턴스를 voteset에 추가
added, err = cs.tryAddVote(msg.Vote, peerID)
// 추가에 성공했다면 메시지 송신
if added {
cs.statesMsgQueue <- mi
}
default:
// err log
return
}