[#396] ir: Support working with sidechain only

NeoFS contract can be deployed in sidechain instead of main chain.

Add `without_mainnet` config flag that can switch IR node to work with
sidechain only. By default this flag is unset.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-21 12:26:18 +03:00 committed by Alex Vanin
parent ba85b9ff25
commit 53b4d6d6d0
2 changed files with 21 additions and 11 deletions

View file

@ -47,6 +47,8 @@ func defaultConfiguration(cfg *viper.Viper) {
cfg.SetDefault("metrics.address", ":9090")
cfg.SetDefault("metrics.shutdown_ttl", "30s")
cfg.SetDefault("without_mainnet", false)
cfg.SetDefault("morph.endpoint.client", "")
cfg.SetDefault("morph.endpoint.notification", "")
cfg.SetDefault("morph.dial_timeout", "10s")

View file

@ -238,6 +238,13 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
return nil, err
}
if cfg.GetBool("without_mainnet") {
// This works as long as event Listener starts listening loop once,
// otherwise Server.Start will run two similar routines.
// This behavior most likely will not change.
server.mainnetListener = server.morphListener
server.mainnetClient = server.morphClient
} else {
mainnetChain := morphChain
mainnetChain.name = mainnetPrefix
@ -252,6 +259,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
if err != nil {
return nil, err
}
}
server.pubKey = crypto.MarshalPublicKey(&server.key.PublicKey)