[#798] pkg/innerring: Store withoutMainNet flag in server

withoutMainNet flag will be reused in runtime server start
to enable main chain block number state saver.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-09-06 15:58:40 +03:00 committed by Alex Vanin
parent 67471a8914
commit 2bcf22ad79

View file

@ -86,6 +86,7 @@ type (
contracts *contracts contracts *contracts
predefinedValidators keys.PublicKeys predefinedValidators keys.PublicKeys
initialEpochTickDelta uint32 initialEpochTickDelta uint32
withoutMainNet bool
// runtime processors // runtime processors
netmapProcessor *netmap.Processor netmapProcessor *netmap.Processor
@ -336,9 +337,9 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
return nil, err return nil, err
} }
withoutMainNet := cfg.GetBool("without_mainnet") server.withoutMainNet = cfg.GetBool("without_mainnet")
if withoutMainNet { if server.withoutMainNet {
// This works as long as event Listener starts listening loop once, // This works as long as event Listener starts listening loop once,
// otherwise Server.Start will run two similar routines. // otherwise Server.Start will run two similar routines.
// This behavior most likely will not change. // This behavior most likely will not change.
@ -365,7 +366,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
server.mainNotaryConfig, server.sideNotaryConfig = parseNotaryConfigs( server.mainNotaryConfig, server.sideNotaryConfig = parseNotaryConfigs(
cfg, cfg,
server.morphClient.ProbeNotary(), server.morphClient.ProbeNotary(),
!withoutMainNet && server.mainnetClient.ProbeNotary(), // if mainnet disabled then notary flag must be disabled too !server.withoutMainNet && server.mainnetClient.ProbeNotary(), // if mainnet disabled then notary flag must be disabled too
) )
log.Debug("notary support", log.Debug("notary support",
@ -376,7 +377,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
// get all script hashes of contracts // get all script hashes of contracts
server.contracts, err = parseContracts( server.contracts, err = parseContracts(
cfg, cfg,
withoutMainNet, server.withoutMainNet,
server.mainNotaryConfig.disabled, server.mainNotaryConfig.disabled,
server.sideNotaryConfig.disabled, server.sideNotaryConfig.disabled,
) )
@ -574,7 +575,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
var alphaSync event.Handler var alphaSync event.Handler
if withoutMainNet { if server.withoutMainNet {
alphaSync = func(event.Event) { alphaSync = func(event.Event) {
log.Debug("alphabet keys sync is disabled") log.Debug("alphabet keys sync is disabled")
} }
@ -674,7 +675,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
return nil, err return nil, err
} }
if !withoutMainNet { if !server.withoutMainNet {
// create mainnnet neofs processor // create mainnnet neofs processor
neofsProcessor, err := neofs.New(&neofs.Params{ neofsProcessor, err := neofs.New(&neofs.Params{
Log: log, Log: log,