events: Fix double trigger in CalledAt

This commit is contained in:
Łukasz Magiera 2019-12-04 13:41:22 +01:00
parent cb19ca499e
commit 7d80cbfbdf
2 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,7 @@ type RevertHandler func(ctx context.Context, ts *types.TipSet) error
type heightHandler struct {
confidence int
called bool
handle HeightHandler
revert RevertHandler

View File

@ -40,6 +40,7 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
ctx, span := trace.StartSpan(ctx, "events.HeightRevert")
err := e.heightTriggers[tid].revert(ctx, ts)
e.heightTriggers[tid].called = false
span.End()
@ -82,6 +83,11 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
apply := func(h uint64, ts *types.TipSet) error {
for _, tid := range e.htTriggerHeights[h] {
hnd := e.heightTriggers[tid]
if hnd.called {
return nil
}
hnd.called = true
triggerH := h - uint64(hnd.confidence)
incTs, err := e.tsc.getNonNull(triggerH)