@ -188,6 +188,10 @@ 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
@ -341,22 +345,14 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) {
consensus . aggregatedCommitSig = aggSig
consensus . commitBitmap = mask
if recvMsg . BlockNum > consensus . blockNum && recvMsg . BlockNum - consensus . blockNum > consensusBlockNumBuffer {
consensus . tryCatchup ( )
if recvMsg . BlockNum > consensus . blockNum {
consensus . getLogger ( ) . Info ( ) . Uint64 ( "MsgBlockNum" , recvMsg . BlockNum ) . Msg ( "[OnCommitted] OUT OF SYNC" )
go func ( ) {
select {
case consensus . BlockNumLowChan <- struct { } { } :
consensus . current . SetMode ( Syncing )
for _ , v := range consensus . consensusTimeout {
v . Stop ( )
}
case <- time . After ( 1 * time . Second ) :
}
} ( )
go consensus . spinUpStateSync ( )
return
}
consensus . tryCatchup ( )
if consensus . IsViewChangingMode ( ) {
consensus . getLogger ( ) . Info ( ) . Msg ( "[OnCommitted] Still in ViewChanging mode, Exiting!!" )
return
@ -370,3 +366,14 @@ 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 ) :
}
}