mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
added config file slice support (#5122)
* added config file slice support * ReadMe update
This commit is contained in:
parent
d794420db8
commit
18f9313c85
42
README.md
42
README.md
@ -175,6 +175,48 @@ C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin
|
||||
**Please also note the default WSL2 environment has its own IP address which does not match the one of the network
|
||||
interface of Windows host: take this into account when configuring NAT for port 30303 on your router.**
|
||||
|
||||
### Using TOML or YAML Config Files
|
||||
|
||||
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
|
||||
|
||||
`./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
|
||||
|
||||
Example of setting up TOML config file
|
||||
|
||||
```
|
||||
`datadir = 'your datadir'
|
||||
port = "1111"
|
||||
chain = "mainnet"
|
||||
http = "true"
|
||||
"private.api.addr"="localhost:9090"
|
||||
|
||||
"http.api" = ["eth","debug","net"]
|
||||
```
|
||||
|
||||
## YAML
|
||||
|
||||
Example of setting up a YAML config file
|
||||
|
||||
```
|
||||
datadir : 'your datadir'
|
||||
port : "1111"
|
||||
chain : "mainnet"
|
||||
http : "true"
|
||||
private.api.addr : "localhost:9090"
|
||||
|
||||
http.api : ["eth","debug","net"]
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Beacon Chain (Consensus Layer)
|
||||
|
||||
Erigon can be used as an Execution Layer (EL) for Consensus Layer clients (CL). Default configuration is OK. CL
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common/dbg"
|
||||
"github.com/ledgerwatch/erigon/cmd/utils"
|
||||
@ -68,7 +70,7 @@ func runErigon(cliCtx *cli.Context) {
|
||||
func setFlagsFromConfigFile(ctx *cli.Context, filePath string) error {
|
||||
fileExtension := filepath.Ext(filePath)
|
||||
|
||||
fileConfig := make(map[string]string)
|
||||
fileConfig := make(map[string]interface{})
|
||||
|
||||
if fileExtension == ".yaml" {
|
||||
yamlFile, err := os.ReadFile(filePath)
|
||||
@ -91,13 +93,25 @@ func setFlagsFromConfigFile(ctx *cli.Context, filePath string) error {
|
||||
} else {
|
||||
return errors.New("config files only accepted are .yaml and .toml")
|
||||
}
|
||||
|
||||
// sets global flags to value in yaml/toml file
|
||||
for key, value := range fileConfig {
|
||||
if !ctx.GlobalIsSet(key) {
|
||||
err := ctx.GlobalSet(key, value)
|
||||
if err != nil {
|
||||
return err
|
||||
if reflect.ValueOf(value).Kind() == reflect.Slice {
|
||||
sliceInterface := value.([]interface{})
|
||||
s := make([]string, len(sliceInterface))
|
||||
for i, v := range sliceInterface {
|
||||
s[i] = v.(string)
|
||||
}
|
||||
fmt.Println(s)
|
||||
err := ctx.GlobalSet(key, strings.Join(s[:], ","))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err := ctx.GlobalSet(key, value.(string))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user