2020-02-11 20:48:03 +00:00
|
|
|
package genesis
|
2020-03-04 21:21:24 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-07-20 15:59:05 +00:00
|
|
|
|
2020-09-07 03:49:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/big"
|
2020-03-04 21:21:24 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
2020-09-18 21:59:27 +00:00
|
|
|
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
2020-03-04 21:21:24 +00:00
|
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
2020-07-23 02:05:11 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
bstore "github.com/filecoin-project/lotus/lib/blockstore"
|
2020-03-04 21:21:24 +00:00
|
|
|
)
|
|
|
|
|
2020-07-20 15:59:05 +00:00
|
|
|
func SetupRewardActor(bs bstore.Blockstore, qaPower big.Int) (*types.Actor, error) {
|
2020-03-04 21:21:24 +00:00
|
|
|
cst := cbor.NewCborStore(bs)
|
|
|
|
|
2020-09-18 21:59:27 +00:00
|
|
|
st := reward0.ConstructState(qaPower)
|
2020-05-12 22:57:18 +00:00
|
|
|
|
2020-03-04 21:21:24 +00:00
|
|
|
hcid, err := cst.Put(context.TODO(), st)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &types.Actor{
|
|
|
|
Code: builtin.RewardActorCodeID,
|
2020-03-07 01:33:24 +00:00
|
|
|
Balance: types.BigInt{Int: build.InitialRewardBalance},
|
2020-03-04 21:21:24 +00:00
|
|
|
Head: hcid,
|
|
|
|
}, nil
|
|
|
|
}
|