Merge pull request #430 from filecoin-project/feat/events-always-revert
events: always call revert in CahinAt
This commit is contained in:
commit
1b1c614301
@ -20,20 +20,12 @@ type heightEvents struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
|
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 {
|
for _, ts := range rev {
|
||||||
// TODO: log error if h below gcconfidence
|
// TODO: log error if h below gcconfidence
|
||||||
// revert height-based triggers
|
// revert height-based triggers
|
||||||
|
|
||||||
revert := func(h uint64, ts *types.TipSet) {
|
revert := func(h uint64, ts *types.TipSet) {
|
||||||
for _, tid := range e.htHeights[h] {
|
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)
|
err := e.heightTriggers[tid].revert(ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("reverting chain trigger (@H %d): %s", h, err)
|
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, applied)
|
||||||
require.Equal(t, false, reverted)
|
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)
|
fcs.advance(10, 1, nil)
|
||||||
require.Equal(t, false, applied)
|
require.Equal(t, false, applied)
|
||||||
require.Equal(t, true, reverted)
|
require.Equal(t, true, reverted)
|
||||||
|
Loading…
Reference in New Issue
Block a user