events: always call revert in CahinAt
This commit is contained in:
parent
65b5bf7570
commit
629717dffb
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user