5fc83f4d05
This way there's a single source of truth. Preparation for fixing https://github.com/filecoin-project/specs-actors/issues/517 (requires changing HAMT parameters).
42 lines
922 B
Go
42 lines
922 B
Go
package genesis
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
|
bstore "github.com/ipfs/go-ipfs-blockstore"
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
)
|
|
|
|
func SetupStorageMarketActor(bs bstore.Blockstore) (*types.Actor, error) {
|
|
store := adt.WrapStore(context.TODO(), cbor.NewCborStore(bs))
|
|
|
|
a, err := adt.MakeEmptyArray(store).Root()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
h, err := adt.MakeEmptyMap(store).Root()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
sms := market.ConstructState(a, h, h)
|
|
|
|
stcid, err := store.Put(store.Context(), sms)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
act := &types.Actor{
|
|
Code: builtin.StorageMarketActorCodeID,
|
|
Head: stcid,
|
|
Balance: types.NewInt(0),
|
|
}
|
|
|
|
return act, nil
|
|
}
|