consensus: perform batched chain's block sync

If there are several blocks from chain, then initialize consensus only for the
latest one.
This commit is contained in:
Anna Shaleva 2023-03-15 17:45:56 +03:00
parent 0b352349eb
commit c7566c2a01

View file

@ -345,15 +345,18 @@ events:
} }
// Always process block event if there is any, we can add one above or external // Always process block event if there is any, we can add one above or external
// services can add several blocks during message processing. // services can add several blocks during message processing.
var latestBlock *coreb.Block
syncLoop: syncLoop:
for { for {
select { select {
case b := <-s.blockEvents: case latestBlock = <-s.blockEvents:
s.handleChainBlock(b)
default: default:
break syncLoop break syncLoop
} }
} }
if latestBlock != nil {
s.handleChainBlock(latestBlock)
}
} }
drainLoop: drainLoop:
for { for {