From 511a5373f66757f23a882960076c7fa6a45d83b2 Mon Sep 17 00:00:00 2001 From: Enrique Jose Avila Asapche Date: Mon, 26 Sep 2022 05:10:14 +0300 Subject: [PATCH] Config flag upgrade (#5491) * allowing different values other than strings * updated readme * ops * better error msg --- README.md | 14 +++++++------- cmd/erigon/main.go | 9 +++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 78b7e0b25..9e7542a74 100644 --- a/README.md +++ b/README.md @@ -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"] diff --git a/cmd/erigon/main.go b/cmd/erigon/main.go index 173a90641..a9618584f 100644 --- a/cmd/erigon/main.go +++ b/cmd/erigon/main.go @@ -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) + } } }