diff --git a/Makefile b/Makefile index 40f0102220..bd51193748 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ build: $(BUILD_DEPS) rm -f lotus lotus-storage-miner go build -o lotus ./cmd/lotus 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 .PHONY: build diff --git a/build/genesis.go b/build/genesis.go new file mode 100644 index 0000000000..29575dd672 --- /dev/null +++ b/build/genesis.go @@ -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 +} diff --git a/build/paramfetch.go b/build/paramfetch.go index b15c9146b1..d534623654 100644 --- a/build/paramfetch.go +++ b/build/paramfetch.go @@ -15,14 +15,14 @@ import ( 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 paramdir = "/var/tmp/filecoin-proof-parameters" -type paramFile struct{ - Cid string `json:"cid"` - Digest string `json:"digest"` +type paramFile struct { + Cid string `json:"cid"` + Digest string `json:"digest"` SectorSize uint64 `json:"sector_size"` } @@ -79,25 +79,25 @@ func doFetch(out string, info paramFile) error { log.Infof("Fetching %s", out) resp, err := http.Get(gateway + info.Cid) - if err != nil { - return err - } - defer resp.Body.Close() - - outf, err := os.Create(out) - if err != nil { - return err - } - defer outf.Close() - - bar := pb.New64(resp.ContentLength) + if err != nil { + return err + } + defer resp.Body.Close() + + outf, err := os.Create(out) + if err != nil { + return err + } + defer outf.Close() + + bar := pb.New64(resp.ContentLength) bar.Units = pb.U_BYTES bar.ShowSpeed = true bar.Start() - _, err = io.Copy(outf, bar.NewProxyReader(resp.Body)) + _, err = io.Copy(outf, bar.NewProxyReader(resp.Body)) - bar.Finish() + bar.Finish() return err } diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index b422eee683..7f7d1ce9bd 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -47,13 +47,14 @@ var initCmd = &cli.Command{ }, Action: func(cctx *cli.Context) error { log.Info("Initializing lotus storage miner") - log.Info("Checking if repo exists") log.Info("Checking proof parameters") if err := build.GetParams(true); err != nil { return xerrors.Errorf("fetching proof parameters: %w", err) } + log.Info("Checking if repo exists") + r, err := repo.NewFS(cctx.String(FlagStorageRepo)) if err != nil { return err diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index b50ea7a938..68bf41b386 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -4,15 +4,14 @@ package main import ( "context" - "github.com/filecoin-project/go-lotus/build" - "golang.org/x/xerrors" "io/ioutil" - rice "github.com/GeertJohan/go.rice" "github.com/multiformats/go-multiaddr" + "golang.org/x/xerrors" "gopkg.in/urfave/cli.v2" "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/modules" "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) } - builtinGen, err := rice.FindBox("../../build/genesis") - 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) - } + genBytes := build.MaybeGenesis() if cctx.String("genesis") != "" { genBytes, err = ioutil.ReadFile(cctx.String("genesis"))