consensus: drain block notification channel after each message
Make blockchain lock less possible.
This commit is contained in:
parent
ea46943815
commit
e57e74692f
1 changed files with 10 additions and 5 deletions
|
@ -337,11 +337,16 @@ events:
|
||||||
case b := <-s.blockEvents:
|
case b := <-s.blockEvents:
|
||||||
s.handleChainBlock(b)
|
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
|
||||||
select {
|
// services can add several blocks during message processing.
|
||||||
case b := <-s.blockEvents:
|
syncLoop:
|
||||||
s.handleChainBlock(b)
|
for {
|
||||||
default:
|
select {
|
||||||
|
case b := <-s.blockEvents:
|
||||||
|
s.handleChainBlock(b)
|
||||||
|
default:
|
||||||
|
break syncLoop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drainLoop:
|
drainLoop:
|
||||||
|
|
Loading…
Reference in a new issue