specs-actors: Finish type cleanup

This commit is contained in:
Łukasz Magiera 2020-02-10 19:21:10 +01:00
parent c72727b4fd
commit 7e70536bf1
8 changed files with 30 additions and 18 deletions

View File

@ -2,11 +2,15 @@
package build
import (
"github.com/filecoin-project/specs-actors/actors/abi"
)
func init() {
InsecurePoStValidation = true
}
var SectorSizes = []uint64{1024}
var SectorSizes = []abi.SectorSize{1024}
// Seconds
const BlockDelay = 6

View File

@ -2,6 +2,8 @@ package build
import (
"math/big"
"github.com/filecoin-project/specs-actors/actors/abi"
)
// Core network constants
@ -12,7 +14,7 @@ import (
const UnixfsChunkSize uint64 = 1 << 20
const UnixfsLinksPerLevel = 1024
func SupportedSectorSize(ssize uint64) bool {
func SupportedSectorSize(ssize abi.SectorSize) bool {
for _, ss := range SectorSizes {
if ssize == ss {
return true

View File

@ -2,7 +2,11 @@
package build
var SectorSizes = []uint64{
import (
"github.com/filecoin-project/specs-actors/actors/abi"
)
var SectorSizes = []abi.SectorSize{
32 << 30,
}

View File

@ -69,7 +69,7 @@ type CreateStorageMinerParams struct {
}
func (spa StoragePowerActor) CreateStorageMiner(act *types.Actor, vmctx types.VMContext, params *CreateStorageMinerParams) ([]byte, ActorError) {
if !build.SupportedSectorSize(uint64(params.SectorSize)) {
if !build.SupportedSectorSize(params.SectorSize) {
return nil, aerrors.Newf(1, "Unsupported sector size: %d", params.SectorSize)
}

View File

@ -134,7 +134,7 @@ var runCmd = &cli.Command{
return err
}
if err := paramfetch.GetParams(build.ParametersJson(), ssize); err != nil {
if err := paramfetch.GetParams(build.ParametersJson(), uint64(ssize)); err != nil {
return xerrors.Errorf("get params: %w", err)
}

View File

@ -9,6 +9,7 @@ import (
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/go-sectorbuilder/fs"
"github.com/filecoin-project/specs-actors/actors/abi"
files "github.com/ipfs/go-ipfs-files"
"golang.org/x/xerrors"
"gopkg.in/cheggaaa/pb.v1"
@ -25,7 +26,7 @@ func (w *worker) sizeForType(typ string) int64 {
return size
}
func (w *worker) fetch(typ string, sectorID uint64) error {
func (w *worker) fetch(typ string, sectorID abi.SectorNumber) error {
outname := filepath.Join(w.repo, typ, w.sb.SectorName(sectorID))
url := w.minerEndpoint + "/remote/" + typ + "/" + fmt.Sprint(sectorID)
@ -77,7 +78,7 @@ func (w *worker) fetch(typ string, sectorID uint64) error {
}
func (w *worker) push(typ string, sectorID uint64) error {
func (w *worker) push(typ string, sectorID abi.SectorNumber) error {
w.limiter.transferLimit <- struct{}{}
defer func() {
<-w.limiter.transferLimit
@ -146,12 +147,12 @@ func (w *worker) push(typ string, sectorID uint64) error {
return w.remove(typ, sectorID)
}
func (w *worker) remove(typ string, sectorID uint64) error {
func (w *worker) remove(typ string, sectorID abi.SectorNumber) error {
filename := filepath.Join(w.repo, typ, w.sb.SectorName(sectorID))
return os.RemoveAll(filename)
}
func (w *worker) fetchSector(sectorID uint64, typ sectorbuilder.WorkerTaskType) error {
func (w *worker) fetchSector(sectorID abi.SectorNumber, typ sectorbuilder.WorkerTaskType) error {
w.limiter.transferLimit <- struct{}{}
defer func() {
<-w.limiter.transferLimit

View File

@ -1,7 +1,6 @@
package main
import (
"bytes"
"context"
"crypto/rand"
"encoding/json"
@ -72,7 +71,7 @@ var initCmd = &cli.Command{
&cli.Uint64Flag{
Name: "sector-size",
Usage: "specify sector size to use",
Value: build.SectorSizes[0],
Value: uint64(build.SectorSizes[0]),
},
&cli.StringFlag{
Name: "pre-sealed-sectors",
@ -279,12 +278,12 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
return err
}
proposalCid, err := sector.Deal.Cid()
pnd, err := cborutil.AsIpld(sector.Deal)
if err != nil {
return err
}
dealKey := datastore.NewKey(deals.ProviderDsPrefix).ChildString(proposalCid.String())
dealKey := datastore.NewKey(deals.ProviderDsPrefix).ChildString(pnd.Cid().String())
proposal, err := utils.ToSharedStorageDealProposal(&sector.Deal)
if err != nil {
@ -293,9 +292,9 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
deal := &deals.MinerDeal{
MinerDeal: storagemarket.MinerDeal{
Proposal: *proposal,
ProposalCid: proposalCid,
ProposalCid: pnd.Cid(),
State: storagemarket.StorageDealActive,
Ref: proposalCid, // TODO: This is super wrong, but there
Ref: pnd.Cid(), // TODO: This is super wrong, but there
// are no params for CommP CIDs, we can't recover unixfs cid easily,
// and this isn't even used after the deal enters Complete state
DealID: dealID,
@ -325,8 +324,9 @@ func findMarketDealID(ctx context.Context, api lapi.FullNode, deal actors.Storag
}
for k, v := range deals {
if bytes.Equal(v.PieceRef, deal.PieceRef) {
return strconv.ParseUint(k, 10, 64)
if v.Proposal.PieceCID.Equals(deal.PieceCID) {
id, err := strconv.ParseUint(k, 10, 64)
return abi.DealID(id), err
}
}

View File

@ -10,6 +10,7 @@ import (
"sync/atomic"
"time"
"github.com/filecoin-project/specs-actors/actors/abi"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -18,7 +19,7 @@ import (
)
func init() {
build.SectorSizes = []uint64{1024}
build.SectorSizes = []abi.SectorSize{1024}
}
func (api *api) Spawn() (nodeInfo, error) {