2019-12-19 18:46:30 +00:00
|
|
|
package stmgr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2019-12-20 09:51:13 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2019-12-19 18:46:30 +00:00
|
|
|
)
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
var ForksAtHeight = map[abi.ChainEpoch]func(context.Context, *StateManager, cid.Cid) (cid.Cid, error){}
|
2020-01-31 23:51:15 +00:00
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
func (sm *StateManager) handleStateForks(ctx context.Context, pstate cid.Cid, height, parentH abi.ChainEpoch) (_ cid.Cid, err error) {
|
2019-12-19 20:00:59 +00:00
|
|
|
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
|
|
|
}
|