|
|
@ -359,9 +359,11 @@ func (srv *Server) dialLoop() { |
|
|
|
rand.Read(target[:]) |
|
|
|
rand.Read(target[:]) |
|
|
|
findresults <- srv.ntab.Lookup(target) |
|
|
|
findresults <- srv.ntab.Lookup(target) |
|
|
|
}() |
|
|
|
}() |
|
|
|
refresh.Stop() |
|
|
|
} else { |
|
|
|
|
|
|
|
// Make sure we check again if the peer count falls
|
|
|
|
|
|
|
|
// below MaxPeers.
|
|
|
|
|
|
|
|
refresh.Reset(refreshPeersInterval) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case dest := <-srv.peerConnect: |
|
|
|
case dest := <-srv.peerConnect: |
|
|
|
dial(dest) |
|
|
|
dial(dest) |
|
|
|
case dests := <-findresults: |
|
|
|
case dests := <-findresults: |
|
|
@ -371,7 +373,10 @@ func (srv *Server) dialLoop() { |
|
|
|
refresh.Reset(refreshPeersInterval) |
|
|
|
refresh.Reset(refreshPeersInterval) |
|
|
|
case dest := <-dialed: |
|
|
|
case dest := <-dialed: |
|
|
|
delete(dialing, dest.ID) |
|
|
|
delete(dialing, dest.ID) |
|
|
|
|
|
|
|
if len(dialing) == 0 { |
|
|
|
|
|
|
|
// Check again immediately after dialing all current candidates.
|
|
|
|
|
|
|
|
refresh.Reset(0) |
|
|
|
|
|
|
|
} |
|
|
|
case <-srv.quit: |
|
|
|
case <-srv.quit: |
|
|
|
// TODO: maybe wait for active dials
|
|
|
|
// TODO: maybe wait for active dials
|
|
|
|
return |
|
|
|
return |
|
|
|