2020-02-11 20:48:03 +00:00
|
|
|
package genesis
|
2020-03-04 21:21:24 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
"github.com/filecoin-project/lotus/chain/store"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
|
|
|
bstore "github.com/ipfs/go-ipfs-blockstore"
|
|
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
|
|
|
)
|
|
|
|
|
|
|
|
func SetupRewardActor(bs bstore.Blockstore) (*types.Actor, error) {
|
|
|
|
cst := cbor.NewCborStore(bs)
|
|
|
|
|
|
|
|
as := store.ActorStore(context.TODO(), bs)
|
2020-04-13 21:05:34 +00:00
|
|
|
emv := adt.MakeEmptyMultimap(as)
|
|
|
|
|
|
|
|
r, err := emv.Root()
|
2020-03-04 21:21:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-04-13 21:05:34 +00:00
|
|
|
st := reward.ConstructState(r)
|
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
|
|
|
|
}
|