refactor: we don't care about the tick time
This commit is contained in:
1 parent
aa1e1b1d6c
commit
f11f84fe17
1 file changed
+6
-6
+6
-6
@@ -67,7 +67,7 @@ func (cm *ConnectionMaker) queryLoop(queryChan <-chan *ConnectionMakerInteractio
|
|||||||
switch {
|
switch {
|
||||||
case query.code == CMInitiate:
|
case query.code == CMInitiate:
|
||||||
cm.cmdLineAddress[NormalisePeerAddr(query.address)] = true
|
cm.cmdLineAddress[NormalisePeerAddr(query.address)] = true
|
||||||
cm.checkStateAndAttemptConnections(time.Now())
|
cm.checkStateAndAttemptConnections()
|
||||||
maybeTick()
|
maybeTick()
|
||||||
case query.code == CMStatus:
|
case query.code == CMStatus:
|
||||||
query.resultChan <- cm.status()
|
query.resultChan <- cm.status()
|
||||||
@@ -76,20 +76,20 @@ func (cm *ConnectionMaker) queryLoop(queryChan <-chan *ConnectionMakerInteractio
|
|||||||
target.attempting = false
|
target.attempting = false
|
||||||
target.tryAfter, target.tryInterval = tryAfter(target.tryInterval)
|
target.tryAfter, target.tryInterval = tryAfter(target.tryInterval)
|
||||||
}
|
}
|
||||||
cm.checkStateAndAttemptConnections(time.Now())
|
cm.checkStateAndAttemptConnections()
|
||||||
maybeTick()
|
maybeTick()
|
||||||
default:
|
default:
|
||||||
log.Fatal("Unexpected connection maker query:", query)
|
log.Fatal("Unexpected connection maker query:", query)
|
||||||
}
|
}
|
||||||
case now := <-tick:
|
case <-tick:
|
||||||
cm.checkStateAndAttemptConnections(now)
|
cm.checkStateAndAttemptConnections()
|
||||||
tick = nil
|
tick = nil
|
||||||
maybeTick()
|
maybeTick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) {
|
func (cm *ConnectionMaker) checkStateAndAttemptConnections() {
|
||||||
ourself := cm.router.Ourself
|
ourself := cm.router.Ourself
|
||||||
validTarget := make(map[string]bool)
|
validTarget := make(map[string]bool)
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
now = time.Now() // make sure we catch items just added
|
now := time.Now() // make sure we catch items just added
|
||||||
for address, target := range cm.targets {
|
for address, target := range cm.targets {
|
||||||
if our_connected_targets[address] {
|
if our_connected_targets[address] {
|
||||||
delete(cm.targets, address)
|
delete(cm.targets, address)
|
||||||
|
|||||||
Reference in new issue
Block a user