2020-02-14 21:38:18 +00:00
|
|
|
package genesis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-07-23 02:05:11 +00:00
|
|
|
|
2020-03-26 10:38:45 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/system"
|
2020-03-26 01:00:25 +00:00
|
|
|
|
2020-02-14 21:38:18 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
|
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
2020-07-23 02:05:11 +00:00
|
|
|
|
2021-01-29 20:01:00 +00:00
|
|
|
bstore "github.com/filecoin-project/lotus/blockstore"
|
2020-07-23 02:05:11 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2020-02-14 21:38:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func SetupSystemActor(bs bstore.Blockstore) (*types.Actor, error) {
|
2020-03-26 10:38:45 +00:00
|
|
|
var st system.State
|
2020-02-14 21:38:18 +00:00
|
|
|
|
|
|
|
cst := cbor.NewCborStore(bs)
|
|
|
|
|
2020-03-26 10:38:45 +00:00
|
|
|
statecid, err := cst.Put(context.TODO(), &st)
|
2020-02-14 21:38:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
act := &types.Actor{
|
|
|
|
Code: builtin.SystemActorCodeID,
|
|
|
|
Head: statecid,
|
|
|
|
}
|
|
|
|
|
|
|
|
return act, nil
|
|
|
|
}
|