[viewchange] should not startNewView is not in viewChange mode

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3409/head
Leo Chen 4 years ago
parent cecdd0da5a
commit 205c77b7da
  1. 8
      consensus/view_change.go
  2. 3
      consensus/view_change_msg.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,

@ -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 {

Loading…
Cancel
Save