diff --git a/core/node/groups.go b/core/node/groups.go index b0c7fbbbd8f..4473f79e83d 100644 --- a/core/node/groups.go +++ b/core/node/groups.go @@ -114,7 +114,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config) fx.Option { maybeProvide(libp2p.NatPortMap, !cfg.Swarm.DisableNatPortMap), maybeProvide(libp2p.AutoRealy, cfg.Swarm.EnableAutoRelay), maybeProvide(libp2p.QUIC, cfg.Experimental.QUIC), - maybeProvide(libp2p.AutoNATService(cfg.Experimental.QUIC), cfg.Swarm.EnableAutoNATService), + maybeInvoke(libp2p.AutoNATService(cfg.Experimental.QUIC), cfg.Swarm.EnableAutoNATService), connmgr, ps, ) diff --git a/core/node/helpers.go b/core/node/helpers.go index 2c91ff5f965..9ecd8036b9f 100644 --- a/core/node/helpers.go +++ b/core/node/helpers.go @@ -43,6 +43,13 @@ func maybeProvide(opt interface{}, enable bool) fx.Option { return fx.Options() } +func maybeInvoke(opt interface{}, enable bool) fx.Option { + if enable { + return fx.Invoke(opt) + } + return fx.Options() +} + // baseProcess creates a goprocess which is closed when the lifecycle signals it to stop func baseProcess(lc fx.Lifecycle) goprocess.Process { p := goprocess.WithParent(goprocess.Background())