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) {
|
||||
if !our_connected_targets[address] {
|
||||
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
|
||||
for address, target := range cm.targets {
|
||||
if our_connected_targets[address] {
|
||||
@@ -154,11 +151,9 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) {
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *ConnectionMaker) addToTargets(address string) {
|
||||
address = NormalisePeerAddr(address)
|
||||
target := cm.targets[address]
|
||||
if target == nil {
|
||||
target = &Target{}
|
||||
func (cm *ConnectionMaker) addTarget(address string) {
|
||||
if _, found := cm.targets[address]; !found {
|
||||
target := &Target{}
|
||||
target.tryAfter, target.tryInterval = tryImmediately()
|
||||
cm.targets[address] = target
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user