SectorSize const

This commit is contained in:
Łukasz Magiera 2019-08-27 21:54:14 +02:00
parent be30bc79a5
commit 6714240653
7 changed files with 12 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
/lotus-storage-miner
/pond
/lotuspond/front/node_modules
/lotuspond/front/build
**/*.h
**/*.a
**/*.pc

View File

@ -3,5 +3,6 @@ package build
// Core network constants
const UnixfsChunkSize uint64 = 1 << 20
const SectorSize = 1024
// TODO: Move other important consts here

View File

@ -1,6 +1,7 @@
package actors
import (
"github.com/filecoin-project/go-lotus/build"
"github.com/filecoin-project/go-lotus/chain/actors/aerrors"
"github.com/filecoin-project/go-lotus/chain/address"
"github.com/filecoin-project/go-lotus/chain/types"
@ -9,8 +10,6 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
)
const SectorSize = 1024
func init() {
cbor.RegisterCborType(StorageMarketState{})
cbor.RegisterCborType(CreateStorageMinerParams{})
@ -104,7 +103,7 @@ func (sma StorageMarketActor) CreateStorageMiner(act *types.Actor, vmctx types.V
}
func SupportedSectorSize(ssize types.BigInt) bool {
if ssize.Uint64() == SectorSize {
if ssize.Uint64() == build.SectorSize {
return true
}
return false

View File

@ -3,6 +3,7 @@ package gen
import (
"context"
"fmt"
"github.com/filecoin-project/go-lotus/build"
actors "github.com/filecoin-project/go-lotus/chain/actors"
"github.com/filecoin-project/go-lotus/chain/address"
@ -168,7 +169,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
params := mustEnc(actors.CreateStorageMinerParams{
Owner: gmcfg.Owner,
Worker: gmcfg.Worker,
SectorSize: types.NewInt(1024),
SectorSize: types.NewInt(build.SectorSize),
PeerID: gmcfg.PeerID,
})

View File

@ -3,6 +3,7 @@ package impl
import (
"context"
"fmt"
"github.com/filecoin-project/go-lotus/build"
"github.com/filecoin-project/go-lotus/storage/sectorblocks"
"io"
"math/rand"
@ -30,7 +31,7 @@ func (sm *StorageMinerAPI) ActorAddresses(context.Context) ([]address.Address, e
}
func (sm *StorageMinerAPI) StoreGarbageData(ctx context.Context) (uint64, error) {
size := uint64(1016) // this is the most data we can fit in a 1024 byte sector
size := uint64(build.SectorSize - 8) // this is the most data we can fit in a sector. TODO: check if correct
name := fmt.Sprintf("fake-file-%d", rand.Intn(100000000))
sectorId, err := sm.Sectors.AddPiece(name, size, io.LimitReader(rand.New(rand.NewSource(42)), 1016))

View File

@ -2,6 +2,7 @@ package modules
import (
"context"
"github.com/filecoin-project/go-lotus/build"
"github.com/filecoin-project/go-lotus/retrieval"
"github.com/filecoin-project/go-lotus/storage/sector"
"path/filepath"
@ -55,7 +56,7 @@ func SectorBuilderConfig(storagePath string) func(dtypes.MetadataDS) (*sectorbui
sb := &sectorbuilder.SectorBuilderConfig{
Miner: minerAddr,
SectorSize: 1024,
SectorSize: build.SectorSize,
MetadataDir: metadata,
SealedDir: sealed,
StagedDir: staging,

View File

@ -3,6 +3,7 @@ package storage
import (
"context"
"fmt"
"github.com/filecoin-project/go-lotus/build"
"github.com/filecoin-project/go-lotus/storage/sector"
"github.com/filecoin-project/go-lotus/api"
@ -102,7 +103,7 @@ func (m *Miner) handlePostingSealedSectors(ctx context.Context) {
func (m *Miner) commitSector(ctx context.Context, sinfo sectorbuilder.SectorSealingStatus) error {
log.Info("committing sector")
ok, err := sectorbuilder.VerifySeal(1024, sinfo.CommR[:], sinfo.CommD[:], sinfo.CommRStar[:], m.maddr, sinfo.SectorID, sinfo.Proof)
ok, err := sectorbuilder.VerifySeal(build.SectorSize, sinfo.CommR[:], sinfo.CommD[:], sinfo.CommRStar[:], m.maddr, sinfo.SectorID, sinfo.Proof)
if err != nil {
log.Error("failed to verify seal we just created: ", err)
}