Commit 2b013042 authored by caopingcp's avatar caopingcp Committed by vipwzw

fix qbft panic

parent 0b8360b0
......@@ -459,7 +459,8 @@ func (node *Node) addPeer(pc *peerConn) error {
}
qbftlog.Info("Added peer", "peer", pc.ip)
stateMsg := MsgInfo{TypeID: ttypes.NewRoundStepID, Msg: node.state.RoundStateMessage(), PeerID: pc.id, PeerIP: pc.ip.String()}
rs := node.state.GetRoundState()
stateMsg := MsgInfo{TypeID: ttypes.NewRoundStepID, Msg: rs.RoundStateMessage(), PeerID: pc.id, PeerIP: pc.ip.String()}
pc.Send(stateMsg)
qbftlog.Info("Send state msg", "msg", stateMsg, "ourIP", node.IP, "ourID", node.ID)
return nil
......
......@@ -412,6 +412,10 @@ func (pc *peerConn) PickSendVote(votes ttypes.VoteSetReader) bool {
}
}
if vote, ok := pc.state.PickVoteToSend(votes); ok {
if vote == nil {
qbftlog.Warn("Pick nil vote", "aggVote", votes.GetAggVote(), "vote", votes)
return false
}
msg := MsgInfo{TypeID: ttypes.VoteID, Msg: vote.QbftVote, PeerID: pc.id, PeerIP: pc.ip.String()}
qbftlog.Debug("Sending vote message", "msg", msg)
if pc.Send(msg) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment