2020-02-11 20:48:03 +00:00
|
|
|
package genesis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/cron"
|
|
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2020-07-23 02:05:11 +00:00
|
|
|
bstore "github.com/filecoin-project/lotus/lib/blockstore"
|
2020-02-11 20:48:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func SetupCronActor(bs bstore.Blockstore) (*types.Actor, error) {
|
|
|
|
cst := cbor.NewCborStore(bs)
|
2020-05-12 23:12:28 +00:00
|
|
|
cas := cron.ConstructState(cron.BuiltInEntries())
|
2020-02-11 20:48:03 +00:00
|
|
|
|
|
|
|
stcid, err := cst.Put(context.TODO(), cas)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &types.Actor{
|
2020-02-25 20:54:58 +00:00
|
|
|
Code: builtin.CronActorCodeID,
|
2020-02-11 20:48:03 +00:00
|
|
|
Head: stcid,
|
|
|
|
Nonce: 0,
|
|
|
|
Balance: types.NewInt(0),
|
|
|
|
}, nil
|
|
|
|
}
|