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:
parent
0b352349eb
commit
c7566c2a01
1 changed files with 5 additions and 2 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue