consensus: drain block notification channel after each message

Make blockchain lock less possible.
This commit is contained in:
Anna Shaleva 2023-03-06 18:27:09 +03:00
parent ea46943815
commit e57e74692f

View file

@ -337,11 +337,16 @@ events:
case b := <-s.blockEvents:
s.handleChainBlock(b)
}
// Always process block event if there is any, we can add one above.
// Always process block event if there is any, we can add one above or external
// services can add several blocks during message processing.
syncLoop:
for {
select {
case b := <-s.blockEvents:
s.handleChainBlock(b)
default:
break syncLoop
}
}
}
drainLoop: