Check if we already have a connection on an address before attempting to connect to it

This commit is contained in:
Bryan Boreham committed 2014-09-09 11:27:46 +01:00
1 parent 6809a43d49
commit 2f53df8a97
2 files changed
+31 -10

No files matched your search

+7 -3
View File
@@ -115,9 +115,13 @@ func (cm *ConnectionMaker) queryLoop(queryChan <-chan *ConnectionMakerInteractio
case now := <-tick:
for address, target := range cm.targets {
if target.state == CMUnconnected && now.After(target.tryAfter) {
target.attemptCount += 1
target.state = CMAttempting
go cm.attemptConnection(address, target.acceptAnyPeer)
if _, found := cm.router.Ourself.ConnectionOn(address); found {
target.state = CMEstablished
} else {
target.attemptCount += 1
target.state = CMAttempting
go cm.attemptConnection(address, target.acceptAnyPeer)
}
}
}
tick = nil