BlockWaiter returns a channel that waits for the block at the given height.
(height uint64)
| 207 | // BlockWaiter returns a channel that |
| 208 | // waits for the block at the given height. |
| 209 | func (c *Chain) BlockWaiter(height uint64) <-chan struct{} { |
| 210 | ch := make(chan struct{}, 1) |
| 211 | go func() { |
| 212 | c.state.cond.L.Lock() |
| 213 | defer c.state.cond.L.Unlock() |
| 214 | for c.state.height < height { |
| 215 | c.state.cond.Wait() |
| 216 | } |
| 217 | ch <- struct{}{} |
| 218 | }() |
| 219 | |
| 220 | return ch |
| 221 | } |