diff options
author | Felix Lange <fjl@twurst.com> | 2016-09-06 06:26:54 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-09-16 17:06:52 +0800 |
commit | f5c432bcab70ddc818db90ae410e07e6253585af (patch) | |
tree | 227e4ae78deeefb5b1060e0a28b0998f18128c02 /p2p | |
parent | 7c12e8ea44129a5f9caa4d5ca9168c059436bb39 (diff) | |
download | dexon-f5c432bcab70ddc818db90ae410e07e6253585af.tar dexon-f5c432bcab70ddc818db90ae410e07e6253585af.tar.gz dexon-f5c432bcab70ddc818db90ae410e07e6253585af.tar.bz2 dexon-f5c432bcab70ddc818db90ae410e07e6253585af.tar.lz dexon-f5c432bcab70ddc818db90ae410e07e6253585af.tar.xz dexon-f5c432bcab70ddc818db90ae410e07e6253585af.tar.zst dexon-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')
-rw-r--r-- | p2p/nat/nat.go | 6 |
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 { |