Merge pull request #636 from filecoin-project/fix/reorg-ops-order

fix ordering of block applies in reorg ops
This commit is contained in:
Łukasz Magiera 2019-11-20 01:09:53 +01:00 committed by GitHub
commit ab8407fb43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View File

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

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

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

View File

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