From 7d80cbfbdfb6b405bdcb68ed11e0a6a9f62c3f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 4 Dec 2019 13:41:22 +0100 Subject: [PATCH] events: Fix double trigger in CalledAt --- chain/events/events.go | 1 + chain/events/events_height.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/chain/events/events.go b/chain/events/events.go index 80028965b..cc51fbfae 100644 --- a/chain/events/events.go +++ b/chain/events/events.go @@ -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 diff --git a/chain/events/events_height.go b/chain/events/events_height.go index e7a81d735..a407d167a 100644 --- a/chain/events/events_height.go +++ b/chain/events/events_height.go @@ -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)