move genesis loading to build pkg
This commit is contained in:
parent
05878f4320
commit
713f08e9bf
2
Makefile
2
Makefile
@ -75,7 +75,7 @@ build: $(BUILD_DEPS)
|
|||||||
rm -f lotus lotus-storage-miner
|
rm -f lotus lotus-storage-miner
|
||||||
go build -o lotus ./cmd/lotus
|
go build -o lotus ./cmd/lotus
|
||||||
go build -o lotus-storage-miner ./cmd/lotus-storage-miner
|
go build -o lotus-storage-miner ./cmd/lotus-storage-miner
|
||||||
rice append --exec lotus -i ./cmd/lotus -i ./build
|
rice append --exec lotus -i ./build
|
||||||
rice append --exec lotus-storage-miner -i ./build
|
rice append --exec lotus-storage-miner -i ./build
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
|
|
||||||
|
17
build/genesis.go
Normal file
17
build/genesis.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package build
|
||||||
|
|
||||||
|
import rice "github.com/GeertJohan/go.rice"
|
||||||
|
|
||||||
|
func MaybeGenesis() []byte {
|
||||||
|
builtinGen, err := rice.FindBox("genesis")
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("loading built-in genesis: %s", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
genBytes, err := builtinGen.Bytes("devnet.car")
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("loading built-in genesis: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return genBytes
|
||||||
|
}
|
@ -15,12 +15,12 @@ import (
|
|||||||
pb "gopkg.in/cheggaaa/pb.v1"
|
pb "gopkg.in/cheggaaa/pb.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("miner")
|
var log = logging.Logger("build")
|
||||||
|
|
||||||
const gateway = "http://198.211.99.118/ipfs/"
|
const gateway = "http://198.211.99.118/ipfs/"
|
||||||
const paramdir = "/var/tmp/filecoin-proof-parameters"
|
const paramdir = "/var/tmp/filecoin-proof-parameters"
|
||||||
|
|
||||||
type paramFile struct{
|
type paramFile struct {
|
||||||
Cid string `json:"cid"`
|
Cid string `json:"cid"`
|
||||||
Digest string `json:"digest"`
|
Digest string `json:"digest"`
|
||||||
SectorSize uint64 `json:"sector_size"`
|
SectorSize uint64 `json:"sector_size"`
|
||||||
|
@ -47,13 +47,14 @@ var initCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
log.Info("Initializing lotus storage miner")
|
log.Info("Initializing lotus storage miner")
|
||||||
log.Info("Checking if repo exists")
|
|
||||||
|
|
||||||
log.Info("Checking proof parameters")
|
log.Info("Checking proof parameters")
|
||||||
if err := build.GetParams(true); err != nil {
|
if err := build.GetParams(true); err != nil {
|
||||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info("Checking if repo exists")
|
||||||
|
|
||||||
r, err := repo.NewFS(cctx.String(FlagStorageRepo))
|
r, err := repo.NewFS(cctx.String(FlagStorageRepo))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -4,15 +4,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/filecoin-project/go-lotus/build"
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
rice "github.com/GeertJohan/go.rice"
|
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-lotus/api"
|
"github.com/filecoin-project/go-lotus/api"
|
||||||
|
"github.com/filecoin-project/go-lotus/build"
|
||||||
"github.com/filecoin-project/go-lotus/node"
|
"github.com/filecoin-project/go-lotus/node"
|
||||||
"github.com/filecoin-project/go-lotus/node/modules"
|
"github.com/filecoin-project/go-lotus/node/modules"
|
||||||
"github.com/filecoin-project/go-lotus/node/modules/testing"
|
"github.com/filecoin-project/go-lotus/node/modules/testing"
|
||||||
@ -57,14 +56,7 @@ var DaemonCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
builtinGen, err := rice.FindBox("../../build/genesis")
|
genBytes := build.MaybeGenesis()
|
||||||
if err != nil {
|
|
||||||
log.Warn("loading built-in genesis: %s", err)
|
|
||||||
}
|
|
||||||
genBytes, err := builtinGen.Bytes("devnet.car")
|
|
||||||
if err != nil {
|
|
||||||
log.Warn("loading built-in genesis: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if cctx.String("genesis") != "" {
|
if cctx.String("genesis") != "" {
|
||||||
genBytes, err = ioutil.ReadFile(cctx.String("genesis"))
|
genBytes, err = ioutil.ReadFile(cctx.String("genesis"))
|
||||||
|
Loading…
Reference in New Issue
Block a user