Skip to content

Commit f5c432b

Browse files
committed
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.
1 parent 7c12e8e commit f5c432b

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

‎p2p/nat/nat.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@ type autodisc struct {
197197

198198
func startautodisc(what string, doit func() Interface) Interface {
199199
// TODO: monitor network configuration and rerun doit when it changes.
200-
ad := &autodisc{what: what, doit: doit}
201-
// Start the auto discovery as early as possible so it is already
202-
// in progress when the rest of the stack calls the methods.
203-
go ad.wait()
204-
return ad
200+
return &autodisc{what: what, doit: doit}
205201
}
206202

207203
func (n *autodisc) AddMapping(protocol string, extport, intport int, name string, lifetime time.Duration) error {

0 commit comments

Comments
 (0)