From 0631b38da1ce27324a74562f4160a853de437efe Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 12 Oct 2022 20:13:57 +0300 Subject: [PATCH] [#1713] ir: Add Neo RPC switch interval to the config Signed-off-by: Pavel Karpy --- cmd/neofs-ir/defaults.go | 2 ++ config/example/ir.env | 2 ++ config/example/ir.yaml | 2 ++ pkg/innerring/innerring.go | 1 + 4 files changed, 7 insertions(+) diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index 6b571a570..09091effa 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -50,9 +50,11 @@ func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("morph.endpoint.client", []string{}) cfg.SetDefault("morph.dial_timeout", 15*time.Second) cfg.SetDefault("morph.validators", []string{}) + cfg.SetDefault("morph.switch_interval", 2*time.Minute) cfg.SetDefault("mainnet.endpoint.client", []string{}) cfg.SetDefault("mainnet.dial_timeout", 15*time.Second) + cfg.SetDefault("mainnet.switch_interval", 2*time.Minute) cfg.SetDefault("wallet.path", "") // inner ring node NEP-6 wallet cfg.SetDefault("wallet.address", "") // account address diff --git a/config/example/ir.env b/config/example/ir.env index 318dd1c3d..235956d86 100644 --- a/config/example/ir.env +++ b/config/example/ir.env @@ -10,10 +10,12 @@ NEOFS_IR_MORPH_DIAL_TIMEOUT=5s NEOFS_IR_MORPH_ENDPOINT_CLIENT_0_ADDRESS="wss://sidechain1.fs.neo.org:30333/ws" NEOFS_IR_MORPH_ENDPOINT_CLIENT_1_ADDRESS="wss://sidechain2.fs.neo.org:30333/ws" NEOFS_IR_MORPH_VALIDATORS="0283120f4c8c1fc1d792af5063d2def9da5fddc90bc1384de7fcfdda33c3860170" +NEOFS_IR_MORPH_SWITCH_INTERVAL=2m NEOFS_IR_MAINNET_DIAL_TIMEOUT=5s NEOFS_IR_MAINNET_ENDPOINT_CLIENT_0_ADDRESS="wss://mainchain1.fs.neo.org:30333/ws" NEOFS_IR_MAINNET_ENDPOINT_CLIENT_1_ADDRESS="wss://mainchain2.fs.neo.org:30333/ws" +NEOFS_IR_MAINNET_SWITCH_INTERVAL=2m NEOFS_IR_CONTROL_AUTHORIZED_KEYS="035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11 028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6" NEOFS_IR_CONTROL_GRPC_ENDPOINT=localhost:8090 diff --git a/config/example/ir.yaml b/config/example/ir.yaml index eacd3ba03..afcd8d0bd 100644 --- a/config/example/ir.yaml +++ b/config/example/ir.yaml @@ -18,9 +18,11 @@ morph: - address: wss://sidechain2.fs.neo.org:30333/ws validators: # List of hex-encoded 33-byte public keys of sidechain validators to vote for at application startup - 0283120f4c8c1fc1d792af5063d2def9da5fddc90bc1384de7fcfdda33c3860170 + switch_interval: 2m # interval b/w RPC switch attempts if the node is not connected to the highest priority node mainnet: dial_timeout: 5s # Timeout for RPC client connection to mainchain; ignore if mainchain is disabled + switch_interval: 2m # interval b/w RPC switch attempts if the node is not connected to the highest priority node endpoint: client: # List of websocket RPC endpoints in mainchain; ignore if mainchain is disabled - address: wss://mainchain1.fs.neo.org:30333/ws diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index 371fad583..53d5f1956 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -1007,6 +1007,7 @@ func createClient(ctx context.Context, p *chainParams, errChan chan<- error) (*c client.WithConnLostCallback(func() { errChan <- fmt.Errorf("%s chain connection has been lost", p.name) }), + client.WithSwitchInterval(p.cfg.GetDuration(p.name+".switch_interval")), ) }