2019-12-19 18:46:30 +00:00
|
|
|
package stmgr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2019-12-20 09:51:13 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2019-12-19 18:46:30 +00:00
|
|
|
)
|
|
|
|
|
2020-02-05 02:26:42 +00:00
|
|
|
var ForksAtHeight = map[uint64]func(context.Context, *StateManager, cid.Cid) (cid.Cid, error){}
|
2020-01-31 23:51:15 +00:00
|
|
|
|
2019-12-19 20:00:59 +00:00
|
|
|
func (sm *StateManager) handleStateForks(ctx context.Context, pstate cid.Cid, height, parentH uint64) (_ cid.Cid, err error) {
|
|
|
|
for i := parentH; i < height; i++ {
|
2020-01-31 23:51:15 +00:00
|
|
|
f, ok := ForksAtHeight[i]
|
|
|
|
if ok {
|
|
|
|
nstate, err := f(ctx, sm, pstate)
|
2020-01-31 01:17:34 +00:00
|
|
|
if err != nil {
|
2020-01-31 23:51:15 +00:00
|
|
|
return cid.Undef, err
|
2020-01-31 01:17:34 +00:00
|
|
|
}
|
2020-01-31 23:51:15 +00:00
|
|
|
pstate = nstate
|
2019-12-19 20:00:59 +00:00
|
|
|
}
|
2019-12-19 18:46:30 +00:00
|
|
|
}
|
2019-12-19 20:00:59 +00:00
|
|
|
|
|
|
|
return pstate, nil
|
2019-12-19 18:46:30 +00:00
|
|
|
}
|