refactoring
- rename addToTargets to addTarget - immediately add to cm.targets; the phasing was unnecessary - don't normalise addresses in addTarget - they are already normalised
This commit is contained in:
1 parent
ef35839d4b
commit
5b18864aec
1 file changed
+4
-9
+4
-9
@@ -105,6 +105,7 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) {
|
|||||||
addTarget := func(address string) {
|
addTarget := func(address string) {
|
||||||
if !our_connected_targets[address] {
|
if !our_connected_targets[address] {
|
||||||
validTarget[address] = true
|
validTarget[address] = true
|
||||||
|
cm.addTarget(address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,10 +130,6 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
for address, _ := range validTarget {
|
|
||||||
cm.addToTargets(address)
|
|
||||||
}
|
|
||||||
|
|
||||||
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] {
|
||||||
@@ -154,11 +151,9 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *ConnectionMaker) addToTargets(address string) {
|
func (cm *ConnectionMaker) addTarget(address string) {
|
||||||
address = NormalisePeerAddr(address)
|
if _, found := cm.targets[address]; !found {
|
||||||
target := cm.targets[address]
|
target := &Target{}
|
||||||
if target == nil {
|
|
||||||
target = &Target{}
|
|
||||||
target.tryAfter, target.tryInterval = tryImmediately()
|
target.tryAfter, target.tryInterval = tryImmediately()
|
||||||
cm.targets[address] = target
|
cm.targets[address] = target
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user