From 101539186ad6a4422b703abf5f8739f26c7a21f3 Mon Sep 17 00:00:00 2001 From: yahtoo Date: Thu, 18 Jul 2019 14:58:50 +0800 Subject: [PATCH] Fix BlockWaiter dead lock (#311) * Fix BlockWaiter dead lock * Opz name of the variable --- protocol/protocol.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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{}{} -- 2.11.0