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 /lotus-storage-miner
/pond /pond
/lotuspond/front/node_modules /lotuspond/front/node_modules
/lotuspond/front/build
**/*.h **/*.h
**/*.a **/*.a
**/*.pc **/*.pc

View File

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

View File

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

View File

@ -3,6 +3,7 @@ package gen
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/filecoin-project/go-lotus/build"
actors "github.com/filecoin-project/go-lotus/chain/actors" actors "github.com/filecoin-project/go-lotus/chain/actors"
"github.com/filecoin-project/go-lotus/chain/address" "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{ params := mustEnc(actors.CreateStorageMinerParams{
Owner: gmcfg.Owner, Owner: gmcfg.Owner,
Worker: gmcfg.Worker, Worker: gmcfg.Worker,
SectorSize: types.NewInt(1024), SectorSize: types.NewInt(build.SectorSize),
PeerID: gmcfg.PeerID, PeerID: gmcfg.PeerID,
}) })

View File

@ -3,6 +3,7 @@ package impl
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/filecoin-project/go-lotus/build"
"github.com/filecoin-project/go-lotus/storage/sectorblocks" "github.com/filecoin-project/go-lotus/storage/sectorblocks"
"io" "io"
"math/rand" "math/rand"
@ -30,7 +31,7 @@ func (sm *StorageMinerAPI) ActorAddresses(context.Context) ([]address.Address, e
} }
func (sm *StorageMinerAPI) StoreGarbageData(ctx context.Context) (uint64, error) { 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)) name := fmt.Sprintf("fake-file-%d", rand.Intn(100000000))
sectorId, err := sm.Sectors.AddPiece(name, size, io.LimitReader(rand.New(rand.NewSource(42)), 1016)) sectorId, err := sm.Sectors.AddPiece(name, size, io.LimitReader(rand.New(rand.NewSource(42)), 1016))

View File

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

View File

@ -3,6 +3,7 @@ package storage
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/filecoin-project/go-lotus/build"
"github.com/filecoin-project/go-lotus/storage/sector" "github.com/filecoin-project/go-lotus/storage/sector"
"github.com/filecoin-project/go-lotus/api" "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 { func (m *Miner) commitSector(ctx context.Context, sinfo sectorbuilder.SectorSealingStatus) error {
log.Info("committing sector") 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 { if err != nil {
log.Error("failed to verify seal we just created: ", err) log.Error("failed to verify seal we just created: ", err)
} }