lotus/chain/gen/genesis/t04_power.go

50 lines
1.3 KiB
Go
Raw Normal View History

2020-02-11 20:48:03 +00:00
package genesis
import (
"context"
2020-02-25 20:54:58 +00:00
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/util/adt"
2020-02-11 20:48:03 +00:00
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
bstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/filecoin-project/lotus/chain/types"
)
func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) {
store := adt.WrapStore(context.TODO(), cbor.NewCborStore(bs))
emptyhamt, err := adt.MakeEmptyMap(store).Root()
2020-02-11 20:48:03 +00:00
if err != nil {
return nil, err
}
sms := &power.State{
2020-07-13 11:35:10 +00:00
TotalRawBytePower: big.NewInt(0),
TotalBytesCommitted: big.NewInt(0),
TotalQualityAdjPower: big.NewInt(0),
TotalQABytesCommitted: big.NewInt(0),
TotalPledgeCollateral: big.NewInt(0),
2020-07-10 05:29:42 +00:00
MinerCount: 0,
MinerAboveMinPowerCount: 0,
CronEventQueue: emptyhamt,
2020-07-16 12:48:20 +00:00
FirstCronEpoch: 0,
2020-07-10 05:29:42 +00:00
Claims: emptyhamt,
ProofValidationBatch: nil,
2020-02-11 20:48:03 +00:00
}
stcid, err := store.Put(store.Context(), sms)
2020-02-11 20:48:03 +00:00
if err != nil {
return nil, err
}
return &types.Actor{
2020-02-25 20:54:58 +00:00
Code: builtin.StoragePowerActorCodeID,
2020-02-11 20:48:03 +00:00
Head: stcid,
Nonce: 0,
Balance: types.NewInt(0),
}, nil
}