From aed83d1660a81e82cc9d176b57d2ec0fc8434b73 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 18 Jul 2022 18:52:51 +0300 Subject: [PATCH] [#1609] config: Remove mainchain section It is deprecated and unused, there is no need to have it in the documentation. Signed-off-by: Evgenii Stratonikov --- cmd/neofs-node/config/mainchain/config.go | 35 ----------------- .../config/mainchain/config_test.go | 38 ------------------- config/example/node.env | 4 -- config/example/node.json | 7 ---- config/example/node.yaml | 6 --- 5 files changed, 90 deletions(-) delete mode 100644 cmd/neofs-node/config/mainchain/config.go delete mode 100644 cmd/neofs-node/config/mainchain/config_test.go diff --git a/cmd/neofs-node/config/mainchain/config.go b/cmd/neofs-node/config/mainchain/config.go deleted file mode 100644 index a231c0153..000000000 --- a/cmd/neofs-node/config/mainchain/config.go +++ /dev/null @@ -1,35 +0,0 @@ -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 a list of the values of "rpc_endpoint" config parameter -// from "mainchain" section. -// -// Returns empty list if the value is not a non-empty string array. -func RPCEndpoint(c *config.Config) []string { - return config.StringSliceSafe(c.Sub(subsection), "rpc_endpoint") -} - -// DialTimeout returns the value of "dial_timeout" config parameter -// from "mainchain" section. -// -// Returns DialTimeoutDefault if the 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 -} diff --git a/cmd/neofs-node/config/mainchain/config_test.go b/cmd/neofs-node/config/mainchain/config_test.go deleted file mode 100644 index 3335ac13c..000000000 --- a/cmd/neofs-node/config/mainchain/config_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package mainchainconfig_test - -import ( - "testing" - "time" - - "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" - mainchainconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/mainchain" - configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test" - "github.com/stretchr/testify/require" -) - -func TestMainchainSection(t *testing.T) { - t.Run("defaults", func(t *testing.T) { - empty := configtest.EmptyConfig() - - require.Empty(t, mainchainconfig.RPCEndpoint(empty)) - require.Equal(t, mainchainconfig.DialTimeoutDefault, mainchainconfig.DialTimeout(empty)) - }) - - const path = "../../../../config/example/node" - - var rpcs = []string{ - "https://rpc1.n3.nspcc.ru:30341", - "https://rpc2.n3.nspcc.ru:30341", - } - - var fileConfigTest = func(c *config.Config) { - require.Equal(t, rpcs, mainchainconfig.RPCEndpoint(c)) - require.Equal(t, 30*time.Second, mainchainconfig.DialTimeout(c)) - } - - configtest.ForEachFileType(path, fileConfigTest) - - t.Run("ENV", func(t *testing.T) { - configtest.ForEnvFileType(path, fileConfigTest) - }) -} diff --git a/config/example/node.env b/config/example/node.env index dc82860e1..1c5c3c99d 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -58,10 +58,6 @@ NEOFS_MORPH_DIAL_TIMEOUT=30s NEOFS_MORPH_DISABLE_CACHE=true NEOFS_MORPH_RPC_ENDPOINT="wss://rpc1.morph.fs.neo.org:40341/ws wss://rpc2.morph.fs.neo.org:40341/ws" -# Main chain section (optional) -NEOFS_MAINCHAIN_DIAL_TIMEOUT=30s -NEOFS_MAINCHAIN_RPC_ENDPOINT="https://rpc1.n3.nspcc.ru:30341 https://rpc2.n3.nspcc.ru:30341" - # API Client section NEOFS_APICLIENT_DIAL_TIMEOUT=15s diff --git a/config/example/node.json b/config/example/node.json index 06d04e107..411b16666 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -99,13 +99,6 @@ "wss://rpc2.morph.fs.neo.org:40341/ws" ] }, - "mainchain": { - "dial_timeout": "30s", - "rpc_endpoint": [ - "https://rpc1.n3.nspcc.ru:30341", - "https://rpc2.n3.nspcc.ru:30341" - ] - }, "apiclient": { "dial_timeout": "15s" }, diff --git a/config/example/node.yaml b/config/example/node.yaml index 1921b1412..79421cc46 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -85,12 +85,6 @@ morph: - wss://rpc1.morph.fs.neo.org:40341/ws - wss://rpc2.morph.fs.neo.org:40341/ws -mainchain: # DEPRECATED section, is not used and not read - dial_timeout: 30s # timeout for main chain NEO RPC client connection - rpc_endpoint: # main chain NEO RPC endpoints; are shuffled and used one by one until the first success - - https://rpc1.n3.nspcc.ru:30341 - - https://rpc2.n3.nspcc.ru:30341 - apiclient: dial_timeout: 15s # timeout for NEOFS API client connection