diff --git a/consensus/view_change.go b/consensus/view_change.go index 600e72b7e..2934afa81 100644 --- a/consensus/view_change.go +++ b/consensus/view_change.go @@ -278,9 +278,17 @@ func (consensus *Consensus) startNewView(viewID uint64, newLeaderPriKey *bls.Pri consensus.mutex.Lock() defer consensus.mutex.Unlock() + if !consensus.IsViewChangingMode() { + return errors.New("not in view changing mode anymore") + } + msgToSend := consensus.constructNewViewMessage( viewID, newLeaderPriKey, ) + if msgToSend == nil { + return errors.New("failed to construct NewView message") + } + if err := consensus.msgSender.SendWithRetry( consensus.blockNum, msg_pb.MessageType_NEWVIEW, diff --git a/consensus/view_change_msg.go b/consensus/view_change_msg.go index 40a366760..4848a6864 100644 --- a/consensus/view_change_msg.go +++ b/consensus/view_change_msg.go @@ -118,6 +118,9 @@ func (consensus *Consensus) constructNewViewMessage(viewID uint64, priKey *bls.P vcMsg.Payload, vcMsg.PreparedBlock = consensus.vc.GetPreparedBlock(consensus.FBFTLog, consensus.blockHash) vcMsg.M2Aggsigs, vcMsg.M2Bitmap = consensus.vc.GetM2Bitmap(viewID) vcMsg.M3Aggsigs, vcMsg.M3Bitmap = consensus.vc.GetM3Bitmap(viewID) + if vcMsg.M3Bitmap == nil || vcMsg.M3Aggsigs == nil { + return nil + } marshaledMessage, err := consensus.signAndMarshalConsensusMessage(message, priKey.Pri) if err != nil {