mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 10:32:19 +00:00
eb4685f3e2
`STAGES_ONLY_BLOCKS=true` may help to produce BlockSnaps by Erigon2 on weak machines - it disabling all stages after StageSenders.
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
package dbg
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/c2h5oh/datasize"
|
|
)
|
|
|
|
func EnvString(envVarName string, defaultVal string) string {
|
|
v, _ := os.LookupEnv(envVarName)
|
|
if v != "" {
|
|
fmt.Printf("[dbg] env %s=%s\n", envVarName, v)
|
|
return v
|
|
}
|
|
return defaultVal
|
|
}
|
|
func EnvBool(envVarName string, defaultVal bool) bool {
|
|
v, _ := os.LookupEnv(envVarName)
|
|
if v == "true" {
|
|
fmt.Printf("[dbg] env %s=%t\n", envVarName, true)
|
|
return true
|
|
}
|
|
if v == "false" {
|
|
fmt.Printf("[dbg] env %s=%t\n", envVarName, false)
|
|
return false
|
|
}
|
|
return defaultVal
|
|
}
|
|
func EnvInt(envVarName string, defaultVal int) int {
|
|
v, _ := os.LookupEnv(envVarName)
|
|
if v != "" {
|
|
i, err := strconv.Atoi(v)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if i < 0 || i > 4 {
|
|
panic(i)
|
|
}
|
|
fmt.Printf("[dbg] env %s=%d\n", envVarName, i)
|
|
return i
|
|
}
|
|
return defaultVal
|
|
}
|
|
func EnvDataSize(envVarName string, defaultVal datasize.ByteSize) datasize.ByteSize {
|
|
v, _ := os.LookupEnv(envVarName)
|
|
if v != "" {
|
|
val, err := datasize.ParseString(v)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Printf("[dbg] env %s=%s\n", envVarName, val)
|
|
return val
|
|
}
|
|
return defaultVal
|
|
}
|