Merge pull request #636 from filecoin-project/fix/reorg-ops-order
fix ordering of block applies in reorg ops
This commit is contained in:
commit
ab8407fb43
@ -83,9 +83,7 @@ func (e *calledEvents) headChangeCalled(rev, app []*types.TipSet) error {
|
||||
e.handleReverts(ts)
|
||||
}
|
||||
|
||||
tail := len(app) - 1
|
||||
for i := range app {
|
||||
ts := app[tail-i]
|
||||
for _, ts := range app {
|
||||
// called triggers
|
||||
|
||||
e.checkNewCalls(ts)
|
||||
|
@ -70,9 +70,8 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
|
||||
}
|
||||
}
|
||||
|
||||
tail := len(app) - 1
|
||||
for i := range app {
|
||||
ts := app[tail-i]
|
||||
ts := app[i]
|
||||
|
||||
if err := e.tsc.add(ts); err != nil {
|
||||
return err
|
||||
|
@ -179,10 +179,6 @@ func (fcs *fakeCS) advance(rev, app int, msgs map[int]cid.Cid, nulls ...int) { /
|
||||
apps = append(apps, ts)
|
||||
}
|
||||
|
||||
for i, j := 0, len(apps)-1; i < j; i, j = i+1, j-1 {
|
||||
apps[i], apps[j] = apps[j], apps[i]
|
||||
}
|
||||
|
||||
fcs.sub(revs, apps)
|
||||
time.Sleep(100 * time.Millisecond) // TODO: :c
|
||||
}
|
||||
|
@ -253,6 +253,13 @@ func (cs *ChainStore) reorgWorker(ctx context.Context) chan<- reorg {
|
||||
log.Error("computing reorg ops failed: ", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// reverse the apply array
|
||||
for i := len(apply)/2 - 1; i >= 0; i-- {
|
||||
opp := len(apply) - 1 - i
|
||||
apply[i], apply[opp] = apply[opp], apply[i]
|
||||
}
|
||||
|
||||
for _, hcf := range cs.headChangeNotifs {
|
||||
if err := hcf(revert, apply); err != nil {
|
||||
log.Error("head change func errored (BAD): ", err)
|
||||
|
Loading…
Reference in New Issue
Block a user