2020-07-24 13:54:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
2021-03-23 12:44:09 +00:00
|
|
|
"time"
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newConfig(path string) (*viper.Viper, error) {
|
2021-06-09 11:03:09 +00:00
|
|
|
const innerRingPrefix = "neofs_ir"
|
|
|
|
|
2020-07-24 13:54:03 +00:00
|
|
|
var (
|
|
|
|
err error
|
|
|
|
v = viper.New()
|
|
|
|
)
|
|
|
|
|
2021-06-09 11:03:09 +00:00
|
|
|
v.SetEnvPrefix(innerRingPrefix)
|
2020-07-24 13:54:03 +00:00
|
|
|
v.AutomaticEnv()
|
|
|
|
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
|
|
|
|
|
|
|
defaultConfiguration(v)
|
|
|
|
|
|
|
|
if path != "" {
|
|
|
|
v.SetConfigFile(path)
|
2022-02-07 15:41:07 +00:00
|
|
|
if strings.HasSuffix(path, ".json") {
|
|
|
|
v.SetConfigType("json")
|
|
|
|
} else {
|
|
|
|
v.SetConfigType("yml")
|
|
|
|
}
|
2020-07-24 13:54:03 +00:00
|
|
|
err = v.ReadInConfig()
|
|
|
|
}
|
|
|
|
|
|
|
|
return v, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultConfiguration(cfg *viper.Viper) {
|
|
|
|
cfg.SetDefault("logger.level", "info")
|
|
|
|
|
2022-07-13 14:07:31 +00:00
|
|
|
cfg.SetDefault("profiler.address", "localhost:6060")
|
2021-05-11 22:59:05 +00:00
|
|
|
cfg.SetDefault("profiler.shutdown_timeout", "30s")
|
2020-07-24 13:54:03 +00:00
|
|
|
|
2022-07-13 14:07:31 +00:00
|
|
|
cfg.SetDefault("metrics.address", "localhost:9090")
|
2021-05-11 22:59:05 +00:00
|
|
|
cfg.SetDefault("metrics.shutdown_timeout", "30s")
|
2020-07-24 13:54:03 +00:00
|
|
|
|
2021-02-21 09:26:18 +00:00
|
|
|
cfg.SetDefault("without_mainnet", false)
|
|
|
|
|
2021-09-06 13:01:50 +00:00
|
|
|
cfg.SetDefault("node.persistent_state.path", ".neofs-ir-state")
|
|
|
|
|
2022-05-05 14:58:27 +00:00
|
|
|
cfg.SetDefault("morph.endpoint.client", []string{})
|
|
|
|
cfg.SetDefault("morph.dial_timeout", 15*time.Second)
|
2020-11-13 11:47:23 +00:00
|
|
|
cfg.SetDefault("morph.validators", []string{})
|
2020-07-24 13:54:03 +00:00
|
|
|
|
2022-05-05 14:58:27 +00:00
|
|
|
cfg.SetDefault("mainnet.endpoint.client", []string{})
|
|
|
|
cfg.SetDefault("mainnet.dial_timeout", 15*time.Second)
|
2020-07-24 13:54:03 +00:00
|
|
|
|
2021-05-31 08:55:38 +00:00
|
|
|
cfg.SetDefault("wallet.path", "") // inner ring node NEP-6 wallet
|
|
|
|
cfg.SetDefault("wallet.address", "") // account address
|
|
|
|
cfg.SetDefault("wallet.password", "") // password
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
cfg.SetDefault("contracts.netmap", "")
|
|
|
|
cfg.SetDefault("contracts.neofs", "")
|
|
|
|
cfg.SetDefault("contracts.balance", "")
|
2020-08-11 12:14:08 +00:00
|
|
|
cfg.SetDefault("contracts.container", "")
|
2020-12-18 09:27:19 +00:00
|
|
|
cfg.SetDefault("contracts.audit", "")
|
2021-02-20 10:44:51 +00:00
|
|
|
cfg.SetDefault("contracts.proxy", "")
|
2021-04-20 15:16:40 +00:00
|
|
|
cfg.SetDefault("contracts.processing", "")
|
2021-03-31 15:41:47 +00:00
|
|
|
cfg.SetDefault("contracts.reputation", "")
|
2022-05-05 14:58:27 +00:00
|
|
|
cfg.SetDefault("contracts.subnet", "")
|
|
|
|
cfg.SetDefault("contracts.proxy", "")
|
2020-07-24 13:54:03 +00:00
|
|
|
|
2021-01-22 15:49:52 +00:00
|
|
|
cfg.SetDefault("timers.emit", "0")
|
2021-01-29 07:48:47 +00:00
|
|
|
cfg.SetDefault("timers.stop_estimation.mul", 1)
|
2021-06-09 11:13:55 +00:00
|
|
|
cfg.SetDefault("timers.stop_estimation.div", 4)
|
2021-02-01 16:20:33 +00:00
|
|
|
cfg.SetDefault("timers.collect_basic_income.mul", 1)
|
2021-06-09 11:13:55 +00:00
|
|
|
cfg.SetDefault("timers.collect_basic_income.div", 2)
|
|
|
|
cfg.SetDefault("timers.distribute_basic_income.mul", 3)
|
|
|
|
cfg.SetDefault("timers.distribute_basic_income.div", 4)
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
cfg.SetDefault("workers.netmap", "10")
|
|
|
|
cfg.SetDefault("workers.balance", "10")
|
|
|
|
cfg.SetDefault("workers.neofs", "10")
|
2020-08-11 12:14:08 +00:00
|
|
|
cfg.SetDefault("workers.container", "10")
|
2020-10-12 10:17:40 +00:00
|
|
|
cfg.SetDefault("workers.alphabet", "10")
|
2021-03-31 15:41:47 +00:00
|
|
|
cfg.SetDefault("workers.reputation", "10")
|
2021-11-26 12:19:20 +00:00
|
|
|
cfg.SetDefault("workers.subnet", "10")
|
2020-10-29 16:09:45 +00:00
|
|
|
|
2021-06-09 11:13:55 +00:00
|
|
|
cfg.SetDefault("netmap_cleaner.enabled", true)
|
2020-10-29 16:09:45 +00:00
|
|
|
cfg.SetDefault("netmap_cleaner.threshold", 3)
|
2020-11-03 08:12:39 +00:00
|
|
|
|
|
|
|
cfg.SetDefault("emit.storage.amount", 0)
|
2020-11-03 11:16:32 +00:00
|
|
|
cfg.SetDefault("emit.mint.cache_size", 1000)
|
|
|
|
cfg.SetDefault("emit.mint.threshold", 1)
|
|
|
|
cfg.SetDefault("emit.mint.value", 20000000) // 0.2 Fixed8
|
2021-03-18 17:42:35 +00:00
|
|
|
cfg.SetDefault("emit.gas.balance_threshold", 0)
|
2020-12-22 11:47:13 +00:00
|
|
|
|
|
|
|
cfg.SetDefault("audit.task.exec_pool_size", 10)
|
|
|
|
cfg.SetDefault("audit.task.queue_capacity", 100)
|
2020-12-23 08:44:29 +00:00
|
|
|
cfg.SetDefault("audit.timeout.get", "5s")
|
|
|
|
cfg.SetDefault("audit.timeout.head", "5s")
|
|
|
|
cfg.SetDefault("audit.timeout.rangehash", "5s")
|
2020-12-23 15:07:10 +00:00
|
|
|
cfg.SetDefault("audit.timeout.search", "10s")
|
2020-12-23 16:53:11 +00:00
|
|
|
cfg.SetDefault("audit.pdp.max_sleep_interval", "5s")
|
|
|
|
cfg.SetDefault("audit.pdp.pairs_pool_size", "10")
|
2020-12-25 07:45:59 +00:00
|
|
|
cfg.SetDefault("audit.por.pool_size", "10")
|
2021-02-02 11:12:41 +00:00
|
|
|
|
|
|
|
cfg.SetDefault("settlement.basic_income_rate", 0)
|
2021-04-07 10:53:13 +00:00
|
|
|
cfg.SetDefault("settlement.audit_fee", 0)
|
2021-02-10 07:26:27 +00:00
|
|
|
|
2021-03-23 12:44:09 +00:00
|
|
|
cfg.SetDefault("indexer.cache_timeout", 15*time.Second)
|
|
|
|
|
2021-02-10 07:26:27 +00:00
|
|
|
cfg.SetDefault("locode.db.path", "")
|
2021-04-29 13:37:16 +00:00
|
|
|
|
|
|
|
// extra fee values for working mode without notary contract
|
2021-12-07 09:54:21 +00:00
|
|
|
cfg.SetDefault("fee.main_chain", 5000_0000) // 0.5 Fixed8
|
|
|
|
cfg.SetDefault("fee.side_chain", 2_0000_0000) // 2.0 Fixed8
|
|
|
|
cfg.SetDefault("fee.named_container_register", 25_0000_0000) // 25.0 Fixed8
|
2021-06-09 15:49:10 +00:00
|
|
|
|
|
|
|
cfg.SetDefault("control.authorized_keys", []string{})
|
|
|
|
cfg.SetDefault("control.grpc.endpoint", "")
|
2021-09-30 08:46:37 +00:00
|
|
|
|
|
|
|
cfg.SetDefault("governance.disable", false)
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|