Merge pull request #365 from filecoin-project/fix/panic-chainat

Fix panic if there is a panic in the hanlder function
This commit is contained in:
Łukasz Magiera 2019-10-15 02:03:28 +02:00 committed by GitHub
commit b2603c801b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
}