fix ordering of block applies in reorg ops

This commit is contained in:
whyrusleeping 2019-11-18 12:18:59 -06:00
parent eeec3c1783
commit ccfa03138d
2 changed files with 8 additions and 2 deletions

View File

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

View File

@ -254,6 +254,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)