lotus/chain/gen/genesis/f02_reward.go

45 lines
1.2 KiB
Go
Raw Normal View History

2020-02-11 20:48:03 +00:00
package genesis
import (
"context"
2022-06-14 15:00:51 +00:00
cbor "github.com/ipfs/go-ipld-cbor"
"golang.org/x/xerrors"
2022-09-06 15:49:29 +00:00
actorstypes "github.com/filecoin-project/go-state-types/actors"
2020-09-07 03:49:10 +00:00
"github.com/filecoin-project/go-state-types/big"
bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
2022-06-14 15:00:51 +00:00
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin/reward"
"github.com/filecoin-project/lotus/chain/types"
)
2022-09-06 15:49:29 +00:00
func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actorstypes.Version) (*types.Actor, error) {
cst := cbor.NewCborStore(bs)
rst, err := reward.MakeState(adt.WrapStore(ctx, cst), av, qaPower)
if err != nil {
return nil, err
}
statecid, err := cst.Put(ctx, rst.GetState())
if err != nil {
return nil, err
}
actcid, ok := actors.GetActorCodeID(av, actors.RewardKey)
if !ok {
return nil, xerrors.Errorf("failed to get reward actor code ID for actors version %d", av)
}
act := &types.Actor{
Code: actcid,
2020-03-07 01:33:24 +00:00
Balance: types.BigInt{Int: build.InitialRewardBalance},
Head: statecid,
}
return act, nil
}