lotus/chain/gen/genesis/t02_reward.go
Łukasz Magiera bb3789b130 Fix ADT uses
2020-04-13 23:06:11 +02:00

39 lines
946 B
Go

package genesis
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)
emv := adt.MakeEmptyMultimap(as)
r, err := emv.Root()
if err != nil {
return nil, err
}
st := reward.ConstructState(r)
hcid, err := cst.Put(context.TODO(), st)
if err != nil {
return nil, err
}
return &types.Actor{
Code: builtin.RewardActorCodeID,
Balance: types.BigInt{Int: build.InitialRewardBalance},
Head: hcid,
}, nil
}