start integrating sector builder

This commit is contained in:
whyrusleeping
2019-07-29 12:08:05 -07:00
parent f80050307c
commit f1432826d5
5 changed files with 105 additions and 0 deletions
+6
View File
@@ -28,6 +28,7 @@ import (
"github.com/filecoin-project/go-lotus/chain/store"
"github.com/filecoin-project/go-lotus/chain/types"
"github.com/filecoin-project/go-lotus/chain/wallet"
"github.com/filecoin-project/go-lotus/lib/sectorbuilder"
"github.com/filecoin-project/go-lotus/node/config"
"github.com/filecoin-project/go-lotus/node/hello"
"github.com/filecoin-project/go-lotus/node/impl"
@@ -246,6 +247,11 @@ func Config(cfg *config.Root) Option {
ApplyIf(func(s *Settings) bool { return s.Online },
Override(StartListeningKey, lp2p.StartListening(cfg.Libp2p.ListenAddresses)),
),
ApplyIf(func(s *Settings) bool { return s.nodeType == nodeStorageMiner },
Override(new(*sectorbuilder.SectorBuilderConfig), modules.SectorBuilderConfig),
Override(new(*sectorbuilder.SectorBuilder), sectorbuilder.New),
),
)
}
+3
View File
@@ -2,10 +2,13 @@ package impl
import (
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/lib/sectorbuilder"
)
type StorageMinerAPI struct {
CommonAPI
SectorBuilder *sectorbuilder.SectorBuilder
}
var _ api.StorageMiner = &StorageMinerAPI{}
+22
View File
@@ -30,8 +30,10 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/chain/address"
"github.com/filecoin-project/go-lotus/chain/store"
"github.com/filecoin-project/go-lotus/chain/types"
"github.com/filecoin-project/go-lotus/lib/sectorbuilder"
"github.com/filecoin-project/go-lotus/node/modules/helpers"
"github.com/filecoin-project/go-lotus/node/repo"
)
@@ -216,3 +218,23 @@ func LoadGenesis(genBytes []byte) func(blockstore.Blockstore) Genesis {
}
}
}
func SectorBuilderConfig(storagePath string) (*sectorbuilder.SectorBuilderConfig, error) {
metadata := filepath.Join(storagePath, "meta")
sealed := filepath.Join(storagePath, "sealed")
staging := filepath.Join(storagePath, "staging")
// TODO: get the address of the miner actor
minerAddr, err := address.NewIDAddress(42)
if err != nil {
return nil, err
}
return &sectorbuilder.SectorBuilderConfig{
Miner: minerAddr,
SectorSize: 1024,
MetadataDir: metadata,
SealedDir: sealed,
StagedDir: staging,
}, nil
}