diff --git a/chain/events/events_height.go b/chain/events/events_height.go index eded0d0c2..12cafbc99 100644 --- a/chain/events/events_height.go +++ b/chain/events/events_height.go @@ -121,8 +121,8 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error { // // ts passed to handlers is the tipset at the specified, or above, if lower tipsets were null func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h uint64) error { - e.lk.Lock() - defer e.lk.Unlock() + + e.lk.Lock() // Tricky locking, check your locks if you modify this function! bestH := e.tsc.best().Height() @@ -140,6 +140,8 @@ func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence bestH = e.tsc.best().Height() } + defer e.lk.Unlock() + if bestH >= h+uint64(confidence)+e.gcConfidence { return nil }