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

Added script to generate config.toml fromstart.sh #518

Merged
merged 7 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/files/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ syncmode = "full"
# snapshot = true
# ethstats = ""

# [requiredblocks]
# ["eth.requiredblocks"]

[p2p]
# maxpeers = 1
Expand Down
2 changes: 2 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ gcmode = "full"
snapshot = true
ethstats = ""

["eth.requiredblocks"]

[p2p]
maxpeers = 30
maxpendpeers = 50
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ require (
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.1.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mo
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChlfo5C6hzIHwPqfFE=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
Expand Down
9 changes: 9 additions & 0 deletions internal/cli/flagset/flagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ func (f *Flagset) Help() string {
return str + strings.Join(items, "\n\n")
}

func (f *Flagset) GetAllFlags() []string {
flags := []string{}
for _, flag := range f.flags {
flags = append(flags, flag.Name)
}

return flags
}

// MarkDown implements cli.MarkDown interface
func (f *Flagset) MarkDown() string {
if len(f.flags) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestFlags(t *testing.T) {
"--dev.period", "2",
"--datadir", "./data",
"--maxpeers", "30",
"--requiredblocks", "a=b",
"--eth.requiredblocks", "a=b",
"--http.api", "eth,web3,bor",
}
err := c.extractFlags(args)
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Config struct {
Identity string `hcl:"identity,optional" toml:"identity,optional"`

// RequiredBlocks is a list of required (block number, hash) pairs to accept
RequiredBlocks map[string]string `hcl:"requiredblocks,optional" toml:"requiredblocks,optional"`
RequiredBlocks map[string]string `hcl:"eth.requiredblocks,optional" toml:"eth.requiredblocks,optional"`

// LogLevel is the level of the logs to put out
LogLevel string `hcl:"log-level,optional" toml:"log-level,optional"`
Expand Down
3 changes: 0 additions & 3 deletions internal/cli/server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ func TestConfigLoadFile(t *testing.T) {

assert.Equal(t, config, &Config{
DataDir: "./data",
RequiredBlocks: map[string]string{
"a": "b",
},
P2P: &P2PConfig{
MaxPeers: 30,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.GcMode,
})
f.MapStringFlag(&flagset.MapStringFlag{
Name: "requiredblocks",
Name: "eth.requiredblocks",
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
pratikspatil024 marked this conversation as resolved.
Show resolved Hide resolved
Value: &c.cliConfig.RequiredBlocks,
})
Expand Down
4 changes: 0 additions & 4 deletions internal/cli/server/testdata/test.hcl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
datadir = "./data"

requiredblocks = {
a = "b"
}

p2p {
maxpeers = 30
}
Expand Down
3 changes: 0 additions & 3 deletions internal/cli/server/testdata/test.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"datadir": "./data",
"requiredblocks": {
"a": "b"
},
"p2p": {
"maxpeers": 30
},
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/testdata/test.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
datadir = "./data"

[requiredblocks]
["eth.requiredblocks"]
a = "b"

[p2p]
Expand Down
Loading