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
// services can add several blocks during message processing.
var latestBlock *coreb.Block
syncLoop:
for {
select {
case b := <-s.blockEvents:
s.handleChainBlock(b)
case latestBlock = <-s.blockEvents:
default:
break syncLoop
}
}
if latestBlock != nil {
s.handleChainBlock(latestBlock)
}
}
drainLoop:
for {