frostfs-node/cmd/neofs-node/config/mainchain/config.go
Alex Vanin a2547da5ae [#493] cmd/node: Fix linter errors in config
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-06-02 16:07:42 +03:00

35 lines
874 B
Go

package mainchainconfig
import (
"time"
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
)
const (
subsection = "mainchain"
// DialTimeoutDefault is a default dial timeout of main chain client connection.
DialTimeoutDefault = 5 * time.Second
)
// RPCEndpoint returns list of values of "rpc_endpoint" config parameter
// from "mainchain" section.
//
// Returns empty list if value is not a non-empty string array.
func RPCEndpoint(c *config.Config) []string {
return config.StringSliceSafe(c.Sub(subsection), "rpc_endpoint")
}
// DialTimeout returns value of "dial_timeout" config parameter
// from "mainchain" section.
//
// Returns DialTimeoutDefault if value is not positive duration.
func DialTimeout(c *config.Config) time.Duration {
v := config.DurationSafe(c.Sub(subsection), "dial_timeout")
if v > 0 {
return v
}
return DialTimeoutDefault
}