* Fix BlockWaiter dead lock
* Opz name of the variable
func (c *Chain) BlockWaiter(height uint64) <-chan struct{} {
ch := make(chan struct{}, 1)
go func() {
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{}{}
c.cond.Wait()
}
ch <- struct{}{}