forked from TrueCloudLab/neoneo-go
Merge pull request #1410 from nspcc-dev/fix-potential-consensus-stall
consensus: fix potential system deadlock
This commit is contained in:
commit
bdee702f76
1 changed files with 18 additions and 7 deletions
|
@ -228,7 +228,20 @@ func (s *service) eventLoop() {
|
|||
case tx := <-s.transactions:
|
||||
s.dbft.OnTransaction(tx)
|
||||
case b := <-s.blockEvents:
|
||||
// We also receive our own blocks here, so check for index.
|
||||
s.handleChainBlock(b)
|
||||
}
|
||||
// Always process block event if there is any, we can add one above.
|
||||
select {
|
||||
case b := <-s.blockEvents:
|
||||
s.handleChainBlock(b)
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) handleChainBlock(b *coreb.Block) {
|
||||
// We can get our own block here, so check for index.
|
||||
if b.Index >= s.dbft.BlockIndex {
|
||||
s.log.Debug("new block in the chain",
|
||||
zap.Uint32("dbft index", s.dbft.BlockIndex),
|
||||
|
@ -236,8 +249,6 @@ func (s *service) eventLoop() {
|
|||
s.dbft.InitializeConsensus(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) validatePayload(p *Payload) bool {
|
||||
validators := s.getValidators()
|
||||
|
|
Loading…
Reference in a new issue