Skip to content

Commit

Permalink
Merge branch 'master' into feat/splitstore-badger-markset
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k authored Jul 23, 2021
2 parents d6ebead + 964df1a commit 5b4d5c2
Show file tree
Hide file tree
Showing 12 changed files with 1,630 additions and 272 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ api-gen:
goimports -w api
.PHONY: api-gen

cfgdoc-gen:
go run ./node/config/cfgdocgen > ./node/config/doc_gen.go

appimage: lotus
rm -rf appimage-builder-cache || true
rm AppDir/io.filecoin.lotus.desktop || true
Expand Down Expand Up @@ -373,7 +376,7 @@ docsgen-openrpc-worker: docsgen-openrpc-bin

.PHONY: docsgen docsgen-md-bin docsgen-openrpc-bin

gen: actors-gen type-gen method-gen docsgen api-gen circleci
gen: actors-gen type-gen method-gen cfgdoc-gen docsgen api-gen circleci
@echo ">>> IF YOU'VE MODIFIED THE CLI, REMEMBER TO ALSO MAKE docsgen-cli"
.PHONY: gen

Expand Down
78 changes: 75 additions & 3 deletions cmd/lotus-storage-miner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,91 @@ import (
"fmt"

"github.com/urfave/cli/v2"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/repo"
)

var configCmd = &cli.Command{
Name: "config",
Usage: "Output default configuration",
Usage: "Manage node config",
Subcommands: []*cli.Command{
configDefaultCmd,
configUpdateCmd,
},
}

var configDefaultCmd = &cli.Command{
Name: "default",
Usage: "Print default node config",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "no-comment",
Usage: "don't comment default values",
},
},
Action: func(cctx *cli.Context) error {
comm, err := config.ConfigComment(config.DefaultStorageMiner())
c := config.DefaultStorageMiner()

cb, err := config.ConfigUpdate(c, nil, !cctx.Bool("no-comment"))
if err != nil {
return err
}
fmt.Println(string(comm))

fmt.Println(string(cb))

return nil
},
}

var configUpdateCmd = &cli.Command{
Name: "updated",
Usage: "Print updated node config",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "no-comment",
Usage: "don't comment default values",
},
},
Action: func(cctx *cli.Context) error {
r, err := repo.NewFS(cctx.String(FlagMinerRepo))
if err != nil {
return err
}

ok, err := r.Exists()
if err != nil {
return err
}

if !ok {
return xerrors.Errorf("repo not initialized")
}

lr, err := r.LockRO(repo.StorageMiner)
if err != nil {
return xerrors.Errorf("locking repo: %w", err)
}

cfgNode, err := lr.Config()
if err != nil {
_ = lr.Close()
return xerrors.Errorf("getting node config: %w", err)
}

if err := lr.Close(); err != nil {
return err
}

cfgDef := config.DefaultStorageMiner()

updated, err := config.ConfigUpdate(cfgNode, cfgDef, !cctx.Bool("no-comment"))
if err != nil {
return err
}

fmt.Print(string(updated))
return nil
},
}
94 changes: 94 additions & 0 deletions cmd/lotus/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package main

import (
"fmt"

"github.com/urfave/cli/v2"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/repo"
)

var configCmd = &cli.Command{
Name: "config",
Usage: "Manage node config",
Subcommands: []*cli.Command{
configDefaultCmd,
configUpdateCmd,
},
}

var configDefaultCmd = &cli.Command{
Name: "default",
Usage: "Print default node config",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "no-comment",
Usage: "don't comment default values",
},
},
Action: func(cctx *cli.Context) error {
c := config.DefaultFullNode()

cb, err := config.ConfigUpdate(c, nil, !cctx.Bool("no-comment"))
if err != nil {
return err
}

fmt.Println(string(cb))

return nil
},
}

var configUpdateCmd = &cli.Command{
Name: "updated",
Usage: "Print updated node config",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "no-comment",
Usage: "don't comment default values",
},
},
Action: func(cctx *cli.Context) error {
r, err := repo.NewFS(cctx.String("repo"))
if err != nil {
return err
}

ok, err := r.Exists()
if err != nil {
return err
}

if !ok {
return xerrors.Errorf("repo not initialized")
}

lr, err := r.LockRO(repo.FullNode)
if err != nil {
return xerrors.Errorf("locking repo: %w", err)
}

cfgNode, err := lr.Config()
if err != nil {
_ = lr.Close()
return xerrors.Errorf("getting node config: %w", err)
}

if err := lr.Close(); err != nil {
return err
}

cfgDef := config.DefaultFullNode()

updated, err := config.ConfigUpdate(cfgNode, cfgDef, !cctx.Bool("no-comment"))
if err != nil {
return err
}

fmt.Print(string(updated))
return nil
},
}
1 change: 1 addition & 0 deletions cmd/lotus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func main() {
local := []*cli.Command{
DaemonCmd,
backupCmd,
configCmd,
}
if AdvanceBlockCmd != nil {
local = append(local, AdvanceBlockCmd)
Expand Down
42 changes: 38 additions & 4 deletions documentation/en/cli-lotus-miner.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COMMANDS:
init Initialize a lotus miner repo
run Start a lotus miner process
stop Stop a running lotus miner
config Output default configuration
config Manage node config
backup Create node metadata backup
version Print version
help, h Shows a list of commands or help for one command
Expand Down Expand Up @@ -145,13 +145,47 @@ OPTIONS:
## lotus-miner config
```
NAME:
lotus-miner config - Output default configuration
lotus-miner config - Manage node config
USAGE:
lotus-miner config [command options] [arguments...]
lotus-miner config command [command options] [arguments...]
COMMANDS:
default Print default node config
updated Print updated node config
help, h Shows a list of commands or help for one command
OPTIONS:
--help, -h show help (default: false)
--help, -h show help (default: false)
--version, -v print the version (default: false)
```

### lotus-miner config default
```
NAME:
lotus-miner config default - Print default node config
USAGE:
lotus-miner config default [command options] [arguments...]
OPTIONS:
--no-comment don't comment default values (default: false)
--help, -h show help (default: false)
```

### lotus-miner config updated
```
NAME:
lotus-miner config updated - Print updated node config
USAGE:
lotus-miner config updated [command options] [arguments...]
OPTIONS:
--no-comment don't comment default values (default: false)
--help, -h show help (default: false)
```

Expand Down
48 changes: 48 additions & 0 deletions documentation/en/cli-lotus.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ VERSION:
COMMANDS:
daemon Start a lotus daemon process
backup Create node metadata backup
config Manage node config
version Print version
help, h Shows a list of commands or help for one command
BASIC:
Expand Down Expand Up @@ -108,6 +109,53 @@ OPTIONS:
```

## lotus config
```
NAME:
lotus config - Manage node config
USAGE:
lotus config command [command options] [arguments...]
COMMANDS:
default Print default node config
updated Print updated node config
help, h Shows a list of commands or help for one command
OPTIONS:
--help, -h show help (default: false)
--version, -v print the version (default: false)
```

### lotus config default
```
NAME:
lotus config default - Print default node config
USAGE:
lotus config default [command options] [arguments...]
OPTIONS:
--no-comment don't comment default values (default: false)
--help, -h show help (default: false)
```

### lotus config updated
```
NAME:
lotus config updated - Print updated node config
USAGE:
lotus config updated [command options] [arguments...]
OPTIONS:
--no-comment don't comment default values (default: false)
--help, -h show help (default: false)
```

## lotus version
```
NAME:
Expand Down
Loading

0 comments on commit 5b4d5c2

Please sign in to comment.