Merge pull request #430 from filecoin-project/feat/events-always-revert

events: always call revert in CahinAt
This commit is contained in:
Łukasz Magiera 2019-10-21 10:10:59 +02:00 committed by GitHub
commit 1b1c614301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -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)

View File

@ -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)