Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve bor server --help #1063

Merged
merged 11 commits into from
Nov 7, 2023
4 changes: 2 additions & 2 deletions docs/cli/attach.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Connect to remote Bor IPC console.

- ```exec```: Command to run in remote console

- ```preload```: Comma separated list of JavaScript files to preload into the console
- ```jspath```: JavaScript root path for `loadScript`

- ```jspath```: JavaScript root path for `loadScript`
- ```preload```: Comma separated list of JavaScript files to preload into the console
14 changes: 9 additions & 5 deletions docs/cli/bootnode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

## Options

- ```listen-addr```: listening address of bootnode (<ip>:<port>) (default: 0.0.0.0:30303)

- ```v5```: Enable UDP v5 (default: false)
- ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode (default: false)

- ```verbosity```: Logging verbosity (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (default: 3)
- ```listen-addr```: listening address of bootnode (<ip>:<port>) (default: 0.0.0.0:30303)

- ```log-level```: log level (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead (default: info)

- ```metrics```: Enable metrics collection and reporting (default: true)

- ```nat```: port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: none)

- ```node-key```: file or hex node key

- ```prometheus-addr```: listening address of bootnode (<ip>:<port>) (default: 127.0.0.1:7071)

- ```save-key```: path to save the ecdsa private key

- ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode (default: false)
- ```v5```: Enable UDP v5 (default: false)

- ```verbosity```: Logging verbosity (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (default: 3)
4 changes: 2 additions & 2 deletions docs/cli/debug_pprof.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ The ```debug pprof <enode>``` command will create an archive containing bor ppro

- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

- ```seconds```: seconds to profile (default: 2)

- ```output```: Output directory

- ```seconds```: seconds to profile (default: 2)

- ```skiptrace```: Skip running the trace (default: false)
224 changes: 112 additions & 112 deletions docs/cli/server.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/cli/snapshot_prune-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ The ```bor snapshot prune-state``` command will prune historical state data with

## Options

- ```datadir```: Path of the data directory to store information
- ```bloomfilter.size```: Size of the bloom filter (default: 2048)

- ```keystore```: Path of the data directory to store keys
- ```datadir```: Path of the data directory to store information

- ```datadir.ancient```: Path of the ancient data directory to store information

- ```bloomfilter.size```: Size of the bloom filter (default: 2048)
- ```keystore```: Path of the data directory to store keys

### Cache Options

Expand Down
20 changes: 19 additions & 1 deletion internal/cli/flagset/flagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
Value Updatable
}

// ByName implements sort.Interface for []*FlagVar based on the Name field.
type ByName []*FlagVar

func (a ByName) Len() int { return len(a) }
func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByName) Less(i, j int) bool { return a[i].Name < a[j].Name }

Check warning on line 47 in internal/cli/flagset/flagset.go

View check run for this annotation

Codecov / codecov/patch

internal/cli/flagset/flagset.go#L45-L47

Added lines #L45 - L47 were not covered by tests

func (f *Flagset) addFlag(fl *FlagVar) {
f.flags[fl.Name] = fl
}
Expand All @@ -48,7 +55,14 @@

items := []string{}

flags := []*FlagVar{}

Check warning on line 58 in internal/cli/flagset/flagset.go

View check run for this annotation

Codecov / codecov/patch

internal/cli/flagset/flagset.go#L58

Added line #L58 was not covered by tests
for _, item := range f.flags {
flags = append(flags, item)
}

Check warning on line 61 in internal/cli/flagset/flagset.go

View check run for this annotation

Codecov / codecov/patch

internal/cli/flagset/flagset.go#L60-L61

Added lines #L60 - L61 were not covered by tests

sort.Sort(ByName(flags))

for _, item := range flags {

Check warning on line 65 in internal/cli/flagset/flagset.go

View check run for this annotation

Codecov / codecov/patch

internal/cli/flagset/flagset.go#L63-L65

Added lines #L63 - L65 were not covered by tests
if item.Default != nil {
items = append(items, fmt.Sprintf(" -%s\n %s (default: %v)", item.Name, item.Usage, item.Default))
} else {
Expand Down Expand Up @@ -102,7 +116,11 @@
items = append(items, fmt.Sprintf("### %s Options", k))
}

for _, item := range groups[k] {
flags := make([]*FlagVar, len(groups[k]))
copy(flags, groups[k])
sort.Sort(ByName(flags))

for _, item := range flags {

Check warning on line 123 in internal/cli/flagset/flagset.go

View check run for this annotation

Codecov / codecov/patch

internal/cli/flagset/flagset.go#L119-L123

Added lines #L119 - L123 were not covered by tests
if item.Default != nil {
items = append(items, fmt.Sprintf("- ```%s```: %s (default: %v)", item.Name, item.Usage, item.Default))
} else {
Expand Down
10 changes: 5 additions & 5 deletions internal/cli/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *Command) Flags(config *Config) *flagset.Flagset {
})
f.IntFlag(&flagset.IntFlag{
Name: "verbosity",
Usage: "Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit), default = 3",
Usage: "Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit)",
Value: &c.cliConfig.Verbosity,
Default: c.cliConfig.Verbosity,
})
Expand Down Expand Up @@ -71,13 +71,13 @@ func (c *Command) Flags(config *Config) *flagset.Flagset {
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "rpc.batchlimit",
Usage: "Maximum number of messages in a batch (default=100, use 0 for no limits)",
Usage: "Maximum number of messages in a batch (use 0 for no limits)",
Value: &c.cliConfig.RPCBatchLimit,
Default: c.cliConfig.RPCBatchLimit,
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "rpc.returndatalimit",
Usage: "Maximum size (in bytes) a result of an rpc request could have (default=100000, use 0 for no limits)",
Usage: "Maximum size (in bytes) a result of an rpc request could have (use 0 for no limits)",
Value: &c.cliConfig.RPCReturnDataLimit,
Default: c.cliConfig.RPCReturnDataLimit,
})
Expand Down Expand Up @@ -433,7 +433,7 @@ func (c *Command) Flags(config *Config) *flagset.Flagset {
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.triesinmemory",
Usage: "Number of block states (tries) to keep in memory (default = 128)",
Usage: "Number of block states (tries) to keep in memory",
Value: &c.cliConfig.Cache.TriesInMemory,
Default: c.cliConfig.Cache.TriesInMemory,
Group: "Cache",
Expand Down Expand Up @@ -788,7 +788,7 @@ func (c *Command) Flags(config *Config) *flagset.Flagset {
})
f.DurationFlag(&flagset.DurationFlag{
Name: "txarrivalwait",
Usage: "Maximum duration to wait for a transaction before explicitly requesting it (defaults to 500ms)",
Usage: "Maximum duration to wait for a transaction before explicitly requesting it",
Value: &c.cliConfig.P2P.TxArrivalWait,
Default: c.cliConfig.P2P.TxArrivalWait,
Group: "P2P",
Expand Down
Loading