[viewchange] rename stopViewChange to startNewView

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3388/head
Leo Chen 4 years ago
parent bdd717edfb
commit 793529ee24
  1. 16
      consensus/view_change.go

@ -170,8 +170,8 @@ func (consensus *Consensus) startViewChange(viewID uint64) {
} }
} }
// stopViewChange stops the current view change // startNewView stops the current view change
func (consensus *Consensus) stopViewChange(viewID uint64, newLeaderPriKey *bls.PrivateKeyWrapper) error { func (consensus *Consensus) startNewView(viewID uint64, newLeaderPriKey *bls.PrivateKeyWrapper) error {
consensus.mutex.Lock() consensus.mutex.Lock()
defer consensus.mutex.Unlock() defer consensus.mutex.Unlock()
@ -190,7 +190,7 @@ func (consensus *Consensus) stopViewChange(viewID uint64, newLeaderPriKey *bls.P
consensus.getLogger().Info(). consensus.getLogger().Info().
Str("myKey", newLeaderPriKey.Pub.Bytes.Hex()). Str("myKey", newLeaderPriKey.Pub.Bytes.Hex()).
Hex("M1Payload", consensus.vc.GetM1Payload()). Hex("M1Payload", consensus.vc.GetM1Payload()).
Msg("[stopViewChange] Sent NewView Messge") Msg("[startNewView] Sent NewView Messge")
consensus.current.SetMode(Normal) consensus.current.SetMode(Normal)
consensus.consensusTimeout[timeoutViewChange].Stop() consensus.consensusTimeout[timeoutViewChange].Stop()
@ -201,7 +201,7 @@ func (consensus *Consensus) stopViewChange(viewID uint64, newLeaderPriKey *bls.P
consensus.getLogger().Info(). consensus.getLogger().Info().
Uint64("viewID", viewID). Uint64("viewID", viewID).
Str("myKey", newLeaderPriKey.Pub.Bytes.Hex()). Str("myKey", newLeaderPriKey.Pub.Bytes.Hex()).
Msg("[stopViewChange] viewChange stopped. I am the New Leader") Msg("[startNewView] viewChange stopped. I am the New Leader")
return nil return nil
} }
@ -269,8 +269,8 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
// no previous prepared message, go straight to normal mode // no previous prepared message, go straight to normal mode
// and start proposing new block // and start proposing new block
if consensus.vc.IsM1PayloadEmpty() { if consensus.vc.IsM1PayloadEmpty() {
if err := consensus.stopViewChange(recvMsg.ViewID, newLeaderPriKey); err != nil { if err := consensus.startNewView(recvMsg.ViewID, newLeaderPriKey); err != nil {
consensus.getLogger().Error().Err(err).Msg("[onViewChange] stopViewChange failed") consensus.getLogger().Error().Err(err).Msg("[onViewChange] startNewView failed")
return return
} }
consensus.ResetState() consensus.ResetState()
@ -287,8 +287,8 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
consensus.getLogger().Error().Err(err).Msg("[onViewChange] self commit failed") consensus.getLogger().Error().Err(err).Msg("[onViewChange] self commit failed")
return return
} }
if err := consensus.stopViewChange(recvMsg.ViewID, newLeaderPriKey); err != nil { if err := consensus.startNewView(recvMsg.ViewID, newLeaderPriKey); err != nil {
consensus.getLogger().Error().Err(err).Msg("[onViewChange] stopViewChange failed") consensus.getLogger().Error().Err(err).Msg("[onViewChange] startNewView failed")
return return
} }
consensus.ResetState() consensus.ResetState()

Loading…
Cancel
Save