[#1170] cmd/node: Remove useless function variable

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-02-07 17:37:06 +03:00 committed by Alex Vanin
parent 622ea4818f
commit 71c75dc7e8

View file

@ -4,7 +4,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"time"
"github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
@ -35,7 +34,7 @@ const (
func initMorphComponents(c *cfg) { func initMorphComponents(c *cfg) {
var err error var err error
fn := func(addresses []string, dialTimeout time.Duration, handler func(*client.Client)) { addresses := morphconfig.RPCEndpoint(c.appCfg)
if len(addresses) == 0 { if len(addresses) == 0 {
fatalOnErr(errors.New("missing Neo RPC endpoints")) fatalOnErr(errors.New("missing Neo RPC endpoints"))
} }
@ -45,20 +44,12 @@ func initMorphComponents(c *cfg) {
}) })
cli, err := client.New(c.key, addresses[0], cli, err := client.New(c.key, addresses[0],
client.WithDialTimeout(dialTimeout), client.WithDialTimeout(morphconfig.DialTimeout(c.appCfg)),
client.WithLogger(c.log), client.WithLogger(c.log),
client.WithExtraEndpoints(addresses[1:]), client.WithExtraEndpoints(addresses[1:]),
client.WithMaxConnectionPerHost(morphconfig.MaxConnPerHost(c.appCfg)), client.WithMaxConnectionPerHost(morphconfig.MaxConnPerHost(c.appCfg)),
) )
if err == nil { if err != nil {
if err := cli.SetGroupSignerScope(); err != nil {
c.log.Info("failed to set group signer scope, continue with Global", zap.Error(err))
}
handler(cli)
return
}
c.log.Info("failed to create neo RPC client", c.log.Info("failed to create neo RPC client",
zap.Any("endpoints", addresses), zap.Any("endpoints", addresses),
zap.String("error", err.Error()), zap.String("error", err.Error()),
@ -67,9 +58,11 @@ func initMorphComponents(c *cfg) {
fatalOnErr(err) fatalOnErr(err)
} }
fn(morphconfig.RPCEndpoint(c.appCfg), morphconfig.DialTimeout(c.appCfg), func(cli *client.Client) { if err := cli.SetGroupSignerScope(); err != nil {
c.cfgMorph.client = cli c.log.Info("failed to set group signer scope, continue with Global", zap.Error(err))
}
c.cfgMorph.client = cli
c.cfgMorph.notaryEnabled = cli.ProbeNotary() c.cfgMorph.notaryEnabled = cli.ProbeNotary()
lookupScriptHashesInNNS(c) // smart contract auto negotiation lookupScriptHashesInNNS(c) // smart contract auto negotiation
@ -86,7 +79,6 @@ func initMorphComponents(c *cfg) {
c.log.Debug("notary support", c.log.Debug("notary support",
zap.Bool("sidechain_enabled", c.cfgMorph.notaryEnabled), zap.Bool("sidechain_enabled", c.cfgMorph.notaryEnabled),
) )
})
wrap, err := nmClient.NewFromMorph(c.cfgMorph.client, c.cfgNetmap.scriptHash, 0, nmClient.TryNotary()) wrap, err := nmClient.NewFromMorph(c.cfgMorph.client, c.cfgNetmap.scriptHash, 0, nmClient.TryNotary())
fatalOnErr(err) fatalOnErr(err)