Fix panic if there is a panic in the hanlder function

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2019-10-14 15:38:47 +02:00
parent b5ed3da230
commit 4c579acdef
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -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
}