diff --git a/router/connection_maker.go b/router/connection_maker.go index 50d62bba..d9820abb 100644 --- a/router/connection_maker.go +++ b/router/connection_maker.go @@ -149,6 +149,18 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections() time.Duration { } }) + return cm.connectToTargets(validTarget, ourConnectedTargets) +} + +func (cm *ConnectionMaker) addTarget(address string) { + if _, found := cm.targets[address]; !found { + target := &Target{} + target.tryAfter, target.tryInterval = tryImmediately() + cm.targets[address] = target + } +} + +func (cm *ConnectionMaker) connectToTargets(validTarget map[string]bool, ourConnectedTargets map[string]bool) time.Duration { now := time.Now() // make sure we catch items just added after := MaxDuration for address, target := range cm.targets { @@ -174,14 +186,6 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections() time.Duration { return after } -func (cm *ConnectionMaker) addTarget(address string) { - if _, found := cm.targets[address]; !found { - target := &Target{} - target.tryAfter, target.tryInterval = tryImmediately() - cm.targets[address] = target - } -} - func (cm *ConnectionMaker) attemptConnection(address string, acceptNewPeer bool) { log.Printf("->[%s] attempting connection\n", address) if err := cm.ourself.CreateConnection(address, acceptNewPeer); err != nil {