Only set genesis once
This commit is contained in:
@@ -76,7 +76,7 @@ var runCmd = &cli.Command{
|
||||
|
||||
ah := &auth.Handler{
|
||||
Verify: minerapi.AuthVerify,
|
||||
Next: rpcServer.ServeHTTP,
|
||||
Next: rpcServer.ServeHTTP,
|
||||
}
|
||||
|
||||
http.Handle("/rpc/v0", ah)
|
||||
|
||||
@@ -6,6 +6,9 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
"github.com/filecoin-project/go-lotus/node/modules"
|
||||
"github.com/filecoin-project/go-lotus/node/modules/testing"
|
||||
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"gopkg.in/urfave/cli.v2"
|
||||
|
||||
@@ -13,6 +16,10 @@ import (
|
||||
"github.com/filecoin-project/go-lotus/node/repo"
|
||||
)
|
||||
|
||||
const (
|
||||
makeGenFlag = "lotus-make-random-genesis"
|
||||
)
|
||||
|
||||
// DaemonCmd is the `go-lotus daemon` command
|
||||
var DaemonCmd = &cli.Command{
|
||||
Name: "daemon",
|
||||
@@ -22,6 +29,15 @@ var DaemonCmd = &cli.Command{
|
||||
Name: "api",
|
||||
Value: "1234",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: makeGenFlag,
|
||||
Value: "",
|
||||
Hidden: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "genesis",
|
||||
Usage: "genesis file to use for first node run",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
ctx := context.Background()
|
||||
@@ -34,6 +50,14 @@ var DaemonCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
genesis := node.Options()
|
||||
if cctx.String(makeGenFlag) != "" {
|
||||
genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag)))
|
||||
}
|
||||
if cctx.String("genesis") != "" {
|
||||
genesis = node.Override(new(modules.Genesis), modules.LoadGenesis(cctx.String("genesis")))
|
||||
}
|
||||
|
||||
var api api.FullNode
|
||||
err = node.New(ctx,
|
||||
node.FullAPI(&api),
|
||||
@@ -41,6 +65,8 @@ var DaemonCmd = &cli.Command{
|
||||
node.Online(),
|
||||
node.Repo(r),
|
||||
|
||||
genesis,
|
||||
|
||||
node.Override(node.SetApiEndpointKey, func(lr repo.LockedRepo) error {
|
||||
apima, err := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/" + cctx.String("api"))
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ func serveRPC(a api.FullNode, addr string) error {
|
||||
|
||||
ah := &auth.Handler{
|
||||
Verify: a.AuthVerify,
|
||||
Next: rpcServer.ServeHTTP,
|
||||
Next: rpcServer.ServeHTTP,
|
||||
}
|
||||
|
||||
http.Handle("/rpc/v0", ah)
|
||||
|
||||
Reference in New Issue
Block a user