From 629717dffbaa89866e0c6a793bd51e8b86646324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 21 Oct 2019 09:54:36 +0200 Subject: [PATCH] events: always call revert in CahinAt --- chain/events/events_height.go | 8 -------- chain/events/events_test.go | 6 ++++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/chain/events/events_height.go b/chain/events/events_height.go index 0b064fe65..2805f38e2 100644 --- a/chain/events/events_height.go +++ b/chain/events/events_height.go @@ -20,20 +20,12 @@ type heightEvents struct { } func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error { - // highest tipset is always the first (see api.ReorgOps) - newH := app[0].Height() - for _, ts := range rev { // TODO: log error if h below gcconfidence // revert height-based triggers revert := func(h uint64, ts *types.TipSet) { for _, tid := range e.htHeights[h] { - // don't revert if newH is above this ts - if newH >= h { - continue - } - err := e.heightTriggers[tid].revert(ts) if err != nil { log.Errorf("reverting chain trigger (@H %d): %s", h, err) diff --git a/chain/events/events_test.go b/chain/events/events_test.go index e2d27ec7a..f672bc5f6 100644 --- a/chain/events/events_test.go +++ b/chain/events/events_test.go @@ -211,6 +211,12 @@ func TestAt(t *testing.T) { require.Equal(t, false, applied) require.Equal(t, false, reverted) + fcs.advance(10, 10, nil) + require.Equal(t, true, applied) + require.Equal(t, true, reverted) + applied = false + reverted = false + fcs.advance(10, 1, nil) require.Equal(t, false, applied) require.Equal(t, true, reverted)