| 193 | } |
| 194 | |
| 195 | func (c *Chain) setState(s *state.Snapshot) { |
| 196 | c.state.cond.L.Lock() |
| 197 | defer c.state.cond.L.Unlock() |
| 198 | |
| 199 | // Multiple goroutines may attempt to set the state at the |
| 200 | // same time. If b is an older block than c.state, ignore it. |
| 201 | if s.Height() <= c.state.snapshot.Height() { |
| 202 | return |
| 203 | } |
| 204 | |
| 205 | c.state.snapshot = s |
| 206 | if s.Height() > c.state.height { |
| 207 | c.state.height = s.Height() |
| 208 | c.state.cond.Broadcast() |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | func (c *Chain) setHeight(h uint64) { |
| 213 | // We update c.state.height from multiple places: |