|
|
|
@ -188,10 +188,6 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { |
|
|
|
|
|
|
|
|
|
// tryCatchup is also run in onCommitted(), so need to lock with commitMutex.
|
|
|
|
|
consensus.tryCatchup() |
|
|
|
|
if recvMsg.BlockNum > consensus.blockNum { |
|
|
|
|
consensus.getLogger().Info().Uint64("MsgBlockNum", recvMsg.BlockNum).Msg("[OnPrepared] OUT OF SYNC") |
|
|
|
|
go consensus.spinUpStateSync() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if consensus.current.Mode() != Normal { |
|
|
|
|
// don't sign the block that is not verified
|
|
|
|
@ -345,14 +341,22 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { |
|
|
|
|
consensus.aggregatedCommitSig = aggSig |
|
|
|
|
consensus.commitBitmap = mask |
|
|
|
|
|
|
|
|
|
consensus.tryCatchup() |
|
|
|
|
|
|
|
|
|
if recvMsg.BlockNum > consensus.blockNum { |
|
|
|
|
if recvMsg.BlockNum > consensus.blockNum && recvMsg.BlockNum-consensus.blockNum > consensusBlockNumBuffer { |
|
|
|
|
consensus.getLogger().Info().Uint64("MsgBlockNum", recvMsg.BlockNum).Msg("[OnCommitted] OUT OF SYNC") |
|
|
|
|
go consensus.spinUpStateSync() |
|
|
|
|
go func() { |
|
|
|
|
select { |
|
|
|
|
case consensus.BlockNumLowChan <- struct{}{}: |
|
|
|
|
consensus.current.SetMode(Syncing) |
|
|
|
|
for _, v := range consensus.consensusTimeout { |
|
|
|
|
v.Stop() |
|
|
|
|
} |
|
|
|
|
case <-time.After(1 * time.Second): |
|
|
|
|
} |
|
|
|
|
}() |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
consensus.tryCatchup() |
|
|
|
|
if consensus.IsViewChangingMode() { |
|
|
|
|
consensus.getLogger().Info().Msg("[OnCommitted] Still in ViewChanging mode, Exiting!!") |
|
|
|
|
return |
|
|
|
@ -366,14 +370,3 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { |
|
|
|
|
} |
|
|
|
|
consensus.consensusTimeout[timeoutConsensus].Start() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (consensus *Consensus) spinUpStateSync() { |
|
|
|
|
select { |
|
|
|
|
case consensus.BlockNumLowChan <- struct{}{}: |
|
|
|
|
consensus.current.SetMode(Syncing) |
|
|
|
|
for _, v := range consensus.consensusTimeout { |
|
|
|
|
v.Stop() |
|
|
|
|
} |
|
|
|
|
case <-time.After(1 * time.Second): |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|