2021-06-01 14:47:19 +00:00
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// RPCEndpoint returns a list of the values of "rpc_endpoint" config parameter
|
2021-06-01 14:47:19 +00:00
|
|
|
// from "mainchain" section.
|
|
|
|
//
|
2022-04-21 11:28:05 +00:00
|
|
|
// Returns empty list if the value is not a non-empty string array.
|
2021-06-01 14:47:19 +00:00
|
|
|
func RPCEndpoint(c *config.Config) []string {
|
|
|
|
return config.StringSliceSafe(c.Sub(subsection), "rpc_endpoint")
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// DialTimeout returns the value of "dial_timeout" config parameter
|
2021-06-01 14:47:19 +00:00
|
|
|
// from "mainchain" section.
|
|
|
|
//
|
2022-04-21 11:28:05 +00:00
|
|
|
// Returns DialTimeoutDefault if the value is not positive duration.
|
2021-06-01 14:47:19 +00:00
|
|
|
func DialTimeout(c *config.Config) time.Duration {
|
|
|
|
v := config.DurationSafe(c.Sub(subsection), "dial_timeout")
|
2021-06-02 12:44:41 +00:00
|
|
|
if v > 0 {
|
2021-06-01 14:47:19 +00:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
return DialTimeoutDefault
|
|
|
|
}
|