From 26bf8925387da164af31b5242bfe80ab8173e9c2 Mon Sep 17 00:00:00 2001 From: yahtoo Date: Thu, 18 Jul 2019 15:44:09 +0800 Subject: [PATCH] Revert "Fix BlockWaiter dead lock (#311)" (#314) This reverts commit 101539186ad6a4422b703abf5f8739f26c7a21f3. --- protocol/protocol.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protocol/protocol.go b/protocol/protocol.go index 314b5683..d7ea9448 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -201,7 +201,9 @@ func (c *Chain) setState(blockHeader, irrBlockHeader *types.BlockHeader, mainBlo func (c *Chain) BlockWaiter(height uint64) <-chan struct{} { ch := make(chan struct{}, 1) go func() { - for bestHeight := c.BestBlockHeight(); bestHeight < height; bestHeight = c.BestBlockHeight() { + c.cond.L.Lock() + defer c.cond.L.Unlock() + for c.bestBlockHeader.Height < height { c.cond.Wait() } ch <- struct{}{} -- 2.11.0