From 83119c00ec0628a9591909979e4bd0a852a6f5fd Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Mon, 2 Nov 2020 11:16:22 +0300 Subject: [PATCH] [#127] Remove magic number from config With neo-project/neo-modules#358 nodes support RPC to return used magic number. Therefore client doesn't need that configuration value any more. Signed-off-by: Alex Vanin --- cmd/neofs-ir/defaults.go | 3 --- pkg/innerring/innerring.go | 2 -- pkg/morph/client/constructor.go | 16 ---------------- 3 files changed, 21 deletions(-) diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index 3ef4c204..e395ef32 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -3,7 +3,6 @@ package main import ( "strings" - "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neofs-node/misc" "github.com/spf13/viper" ) @@ -51,12 +50,10 @@ func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("morph.endpoint.client", "") cfg.SetDefault("morph.endpoint.notification", "") cfg.SetDefault("morph.dial_timeout", "10s") - cfg.SetDefault("morph.magic_number", uint32(netmode.PrivNet)) cfg.SetDefault("mainnet.endpoint.client", "") cfg.SetDefault("mainnet.endpoint.notification", "") cfg.SetDefault("mainnet.dial_timeout", "10s") - cfg.SetDefault("mainnet.magic_number", uint32(netmode.PrivNet)) cfg.SetDefault("key", "") // inner ring node key diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index 85179ccb..029b0147 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -4,7 +4,6 @@ import ( "context" "crypto/ecdsa" - "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/util" crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-node/pkg/innerring/invoke" @@ -302,7 +301,6 @@ func createClient(ctx context.Context, p *chainParams) (*client.Client, error) { client.WithContext(ctx), client.WithLogger(p.log), client.WithDialTimeout(p.cfg.GetDuration(p.name+".dial_timeouts")), - client.WithMagic(netmode.Magic(p.cfg.GetUint32(p.name+".magic_number"))), client.WithGasContract(p.gas), ) } diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 5ab57ebd..14610e92 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -5,7 +5,6 @@ import ( "crypto/ecdsa" "time" - "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/nspcc-dev/neo-go/pkg/util" @@ -24,8 +23,6 @@ type cfg struct { dialTimeout time.Duration // client dial timeout - magic netmode.Magic // type of Neo blockchain network - logger *logger.Logger // logging component gas util.Uint160 // native gas script-hash @@ -33,13 +30,10 @@ type cfg struct { const defaultDialTimeout = 5 * time.Second -const defaultMagic = netmode.PrivNet - func defaultConfig() *cfg { return &cfg{ ctx: context.Background(), dialTimeout: defaultDialTimeout, - magic: defaultMagic, logger: zap.L(), gas: util.Uint160{}, } @@ -131,16 +125,6 @@ func WithDialTimeout(dur time.Duration) Option { } } -// WithMagic returns a client constructor option -// that specifies neo blockchain network type. -// -// If option not provided, netmode.PrivNet is used. -func WithMagic(mag netmode.Magic) Option { - return func(c *cfg) { - c.magic = mag - } -} - // WithLogger returns a client constructor option // that specifies the component for writing log messages. //