forked from TrueCloudLab/frostfs-node
[#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 <alexey@nspcc.ru>
This commit is contained in:
parent
174efc9df3
commit
83119c00ec
3 changed files with 0 additions and 21 deletions
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
|
||||||
"github.com/nspcc-dev/neofs-node/misc"
|
"github.com/nspcc-dev/neofs-node/misc"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
@ -51,12 +50,10 @@ func defaultConfiguration(cfg *viper.Viper) {
|
||||||
cfg.SetDefault("morph.endpoint.client", "")
|
cfg.SetDefault("morph.endpoint.client", "")
|
||||||
cfg.SetDefault("morph.endpoint.notification", "")
|
cfg.SetDefault("morph.endpoint.notification", "")
|
||||||
cfg.SetDefault("morph.dial_timeout", "10s")
|
cfg.SetDefault("morph.dial_timeout", "10s")
|
||||||
cfg.SetDefault("morph.magic_number", uint32(netmode.PrivNet))
|
|
||||||
|
|
||||||
cfg.SetDefault("mainnet.endpoint.client", "")
|
cfg.SetDefault("mainnet.endpoint.client", "")
|
||||||
cfg.SetDefault("mainnet.endpoint.notification", "")
|
cfg.SetDefault("mainnet.endpoint.notification", "")
|
||||||
cfg.SetDefault("mainnet.dial_timeout", "10s")
|
cfg.SetDefault("mainnet.dial_timeout", "10s")
|
||||||
cfg.SetDefault("mainnet.magic_number", uint32(netmode.PrivNet))
|
|
||||||
|
|
||||||
cfg.SetDefault("key", "") // inner ring node key
|
cfg.SetDefault("key", "") // inner ring node key
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring/invoke"
|
"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.WithContext(ctx),
|
||||||
client.WithLogger(p.log),
|
client.WithLogger(p.log),
|
||||||
client.WithDialTimeout(p.cfg.GetDuration(p.name+".dial_timeouts")),
|
client.WithDialTimeout(p.cfg.GetDuration(p.name+".dial_timeouts")),
|
||||||
client.WithMagic(netmode.Magic(p.cfg.GetUint32(p.name+".magic_number"))),
|
|
||||||
client.WithGasContract(p.gas),
|
client.WithGasContract(p.gas),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"time"
|
"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/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
@ -24,8 +23,6 @@ type cfg struct {
|
||||||
|
|
||||||
dialTimeout time.Duration // client dial timeout
|
dialTimeout time.Duration // client dial timeout
|
||||||
|
|
||||||
magic netmode.Magic // type of Neo blockchain network
|
|
||||||
|
|
||||||
logger *logger.Logger // logging component
|
logger *logger.Logger // logging component
|
||||||
|
|
||||||
gas util.Uint160 // native gas script-hash
|
gas util.Uint160 // native gas script-hash
|
||||||
|
@ -33,13 +30,10 @@ type cfg struct {
|
||||||
|
|
||||||
const defaultDialTimeout = 5 * time.Second
|
const defaultDialTimeout = 5 * time.Second
|
||||||
|
|
||||||
const defaultMagic = netmode.PrivNet
|
|
||||||
|
|
||||||
func defaultConfig() *cfg {
|
func defaultConfig() *cfg {
|
||||||
return &cfg{
|
return &cfg{
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
dialTimeout: defaultDialTimeout,
|
dialTimeout: defaultDialTimeout,
|
||||||
magic: defaultMagic,
|
|
||||||
logger: zap.L(),
|
logger: zap.L(),
|
||||||
gas: util.Uint160{},
|
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
|
// WithLogger returns a client constructor option
|
||||||
// that specifies the component for writing log messages.
|
// that specifies the component for writing log messages.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue