core: fix autonat construction
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
May 1, 2019 at 15:21 UTC
b57956c5fb53f49e18c968291e16feee29892048
2 files changed
+8
-1
core/node/groups.go
+1
-1
@@ -114,7 +114,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config) fx.Option {
114
maybeProvide(libp2p.NatPortMap, !cfg.Swarm.DisableNatPortMap),
115
maybeProvide(libp2p.AutoRealy, cfg.Swarm.EnableAutoRelay),
116
maybeProvide(libp2p.QUIC, cfg.Experimental.QUIC),
117
- maybeProvide(libp2p.AutoNATService(cfg.Experimental.QUIC), cfg.Swarm.EnableAutoNATService),
117
+ maybeInvoke(libp2p.AutoNATService(cfg.Experimental.QUIC), cfg.Swarm.EnableAutoNATService),
118
connmgr,
119
ps,
120
)
core/node/helpers.go
+7
@@ -43,6 +43,13 @@ func maybeProvide(opt interface{}, enable bool) fx.Option {
43
return fx.Options()
44
}
45
46
+func maybeInvoke(opt interface{}, enable bool) fx.Option {
47
+ if enable {
48
+ return fx.Invoke(opt)
49
+ }
50
+ return fx.Options()
51
+}
52
+
53
// baseProcess creates a goprocess which is closed when the lifecycle signals it to stop
54
func baseProcess(lc fx.Lifecycle) goprocess.Process {
55
p := goprocess.WithParent(goprocess.Background())