X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=protocol%2Fprotocol.go;h=d7ea94484e8986833e1f2143f3b95e2fcd524dac;hb=refs%2Fheads%2Frevert-357-master;hp=314b56830ed1d85bc5eaba99b7721ccbeaeccd17;hpb=101539186ad6a4422b703abf5f8739f26c7a21f3;p=bytom%2Fvapor.git 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{}{}