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