[#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,30 +34,22 @@ 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"))
} }
rand.Shuffle(len(addresses), func(i, j int) { rand.Shuffle(len(addresses), func(i, j int) {
addresses[i], addresses[j] = addresses[j], addresses[i] addresses[i], addresses[j] = addresses[j], addresses[i]
}) })
cli, err := client.New(c.key, addresses[0],
client.WithDialTimeout(dialTimeout),
client.WithLogger(c.log),
client.WithExtraEndpoints(addresses[1:]),
client.WithMaxConnectionPerHost(morphconfig.MaxConnPerHost(c.appCfg)),
)
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
}
cli, err := client.New(c.key, addresses[0],
client.WithDialTimeout(morphconfig.DialTimeout(c.appCfg)),
client.WithLogger(c.log),
client.WithExtraEndpoints(addresses[1:]),
client.WithMaxConnectionPerHost(morphconfig.MaxConnPerHost(c.appCfg)),
)
if err != nil {
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,26 +58,27 @@ 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.notaryEnabled = cli.ProbeNotary() c.cfgMorph.client = cli
c.cfgMorph.notaryEnabled = cli.ProbeNotary()
lookupScriptHashesInNNS(c) // smart contract auto negotiation lookupScriptHashesInNNS(c) // smart contract auto negotiation
if c.cfgMorph.notaryEnabled { if c.cfgMorph.notaryEnabled {
err = c.cfgMorph.client.EnableNotarySupport( err = c.cfgMorph.client.EnableNotarySupport(
client.WithProxyContract( client.WithProxyContract(
c.cfgMorph.proxyScriptHash, c.cfgMorph.proxyScriptHash,
), ),
)
fatalOnErr(err)
}
c.log.Debug("notary support",
zap.Bool("sidechain_enabled", c.cfgMorph.notaryEnabled),
) )
}) fatalOnErr(err)
}
c.log.Debug("notary support",
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)