From: yahtoo Date: Thu, 18 Jul 2019 06:58:50 +0000 (+0800) Subject: Fix BlockWaiter dead lock (#311) X-Git-Tag: v1.0.5~113 X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=commitdiff_plain;h=101539186ad6a4422b703abf5f8739f26c7a21f3 Fix BlockWaiter dead lock (#311) * Fix BlockWaiter dead lock * Opz name of the variable --- diff --git a/protocol/protocol.go b/protocol/protocol.go index d7ea9448..314b5683 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -201,9 +201,7 @@ func (c *Chain) setState(blockHeader, irrBlockHeader *types.BlockHeader, mainBlo func (c *Chain) BlockWaiter(height uint64) <-chan struct{} { ch := make(chan struct{}, 1) go func() { - c.cond.L.Lock() - defer c.cond.L.Unlock() - for c.bestBlockHeader.Height < height { + for bestHeight := c.BestBlockHeight(); bestHeight < height; bestHeight = c.BestBlockHeight() { c.cond.Wait() } ch <- struct{}{}