lib/connections: Don't look at devices that are already optimally connected

Just an optimization. Required exposing the priority from the factory,
so made that an interface with an extra method instead of just a func
type.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3071
This commit is contained in:
Jakob Borg
2016-05-09 15:33:25 +00:00
committed by Audrius Butkevicius
parent 31f64186ae
commit d77d8ff803
4 changed files with 35 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ const tcpPriority = 10
func init() {
for _, scheme := range []string{"tcp", "tcp4", "tcp6"} {
dialers[scheme] = newTCPDialer
dialers[scheme] = tcpDialerFactory{}
}
}
@@ -67,9 +67,15 @@ func (d *tcpDialer) String() string {
return "TCP Dialer"
}
func newTCPDialer(cfg *config.Wrapper, tlsCfg *tls.Config) genericDialer {
type tcpDialerFactory struct{}
func (tcpDialerFactory) New(cfg *config.Wrapper, tlsCfg *tls.Config) genericDialer {
return &tcpDialer{
cfg: cfg,
tlsCfg: tlsCfg,
}
}
func (tcpDialerFactory) Priority() int {
return tcpPriority
}