aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/nat
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-09-06 06:26:54 +0800
committerFelix Lange <fjl@twurst.com>2016-09-16 17:06:52 +0800
commitf5c432bcab70ddc818db90ae410e07e6253585af (patch)
tree227e4ae78deeefb5b1060e0a28b0998f18128c02 /p2p/nat
parent7c12e8ea44129a5f9caa4d5ca9168c059436bb39 (diff)
downloadgo-tangerine-f5c432bcab70ddc818db90ae410e07e6253585af.tar
go-tangerine-f5c432bcab70ddc818db90ae410e07e6253585af.tar.gz
go-tangerine-f5c432bcab70ddc818db90ae410e07e6253585af.tar.bz2
go-tangerine-f5c432bcab70ddc818db90ae410e07e6253585af.tar.lz
go-tangerine-f5c432bcab70ddc818db90ae410e07e6253585af.tar.xz
go-tangerine-f5c432bcab70ddc818db90ae410e07e6253585af.tar.zst
go-tangerine-f5c432bcab70ddc818db90ae410e07e6253585af.zip
p2p/nat: delay auto discovery until first use
Port mapper auto discovery used to run immediately after parsing the --nat flag, giving it a slight performance boost. But this is becoming inconvenient because we create node.Node for all geth operations including account management and bare chain interaction. Delay autodiscovery until the first use instead, which avoids any network interaction until the node is actually started.
Diffstat (limited to 'p2p/nat')
-rw-r--r--p2p/nat/nat.go6
1 files changed, 1 insertions, 5 deletions
diff --git a/p2p/nat/nat.go b/p2p/nat/nat.go
index 505a1fc77..42f615f36 100644
--- a/p2p/nat/nat.go
+++ b/p2p/nat/nat.go
@@ -197,11 +197,7 @@ type autodisc struct {
func startautodisc(what string, doit func() Interface) Interface {
// TODO: monitor network configuration and rerun doit when it changes.
- ad := &autodisc{what: what, doit: doit}
- // Start the auto discovery as early as possible so it is already
- // in progress when the rest of the stack calls the methods.
- go ad.wait()
- return ad
+ return &autodisc{what: what, doit: doit}
}
func (n *autodisc) AddMapping(protocol string, extport, intport int, name string, lifetime time.Duration) error {