Skip to content

Commit

Permalink
Config flag upgrade (#5491)
Browse files Browse the repository at this point in the history
* allowing different values other than strings

* updated readme

* ops

* better error msg
  • Loading branch information
enriavil1 authored Sep 26, 2022
1 parent fdb83de commit 511a537
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,36 +192,36 @@ C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin
You can set Erigon flags through a YAML or TOML configuration file with the flag `--config`. The flags set in the configuration
file can be overwritten by writing the flags directly on Erigon command line

## Example
### Example

`./build/bin/erigon --config ./config.yaml --chain=goerli

Assuming we have `chain : "mainnet" in our configuration file, by adding `--chain=goerli` allows the overwrite of the flag inside
of the yaml configuration file and sets the chain to goerli

## TOML
### TOML

Example of setting up TOML config file

```
`datadir = 'your datadir'
port = "1111"
port = 1111
chain = "mainnet"
http = "true"
http = true
"private.api.addr"="localhost:9090"
"http.api" = ["eth","debug","net"]
```

## YAML
### YAML

Example of setting up a YAML config file

```
datadir : 'your datadir'
port : "1111"
port : 1111
chain : "mainnet"
http : "true"
http : true
private.api.addr : "localhost:9090"
http.api : ["eth","debug","net"]
Expand Down
9 changes: 5 additions & 4 deletions cmd/erigon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ func setFlagsFromConfigFile(ctx *cli.Context, filePath string) error {
sliceInterface := value.([]interface{})
s := make([]string, len(sliceInterface))
for i, v := range sliceInterface {
s[i] = v.(string)
s[i] = fmt.Sprintf("%v", v)
}
err := ctx.GlobalSet(key, strings.Join(s, ","))
if err != nil {
return err
return fmt.Errorf("failed setting %s flag with values=%s error=%s", key, s, err)
}
} else {
err := ctx.GlobalSet(key, value.(string))
err := ctx.GlobalSet(key, fmt.Sprintf("%v", value))
if err != nil {
return err
return fmt.Errorf("failed setting %s flag with value=%v error=%s", key, value, err)

}
}
}
Expand Down

0 comments on commit 511a537

Please sign in to comment.