Commit 4a69fa2f authored by vyzo's avatar vyzo

remove dial batching

parent 13d35565
...@@ -480,37 +480,17 @@ loop: ...@@ -480,37 +480,17 @@ loop:
} }
case <-triggerDial: case <-triggerDial:
// we dial batches of addresses together, logically belonging to the same batch for _, addr := range nextDial {
// after a batch of addresses has been dialed, we add a delay before initiating the next batch
dialed := false
last := 0
next := 0
for i, addr := range nextDial {
if dialed && !s.sameAddrBatch(nextDial[last], addr) {
break
}
next = i + 1
// spawn the dial // spawn the dial
ad := pending[addr] ad := pending[addr]
err := s.dialNextAddr(ad.ctx, p, addr, resch) err := s.dialNextAddr(ad.ctx, p, addr, resch)
if err != nil { if err != nil {
dispatchError(ad, err) dispatchError(ad, err)
continue
} }
ad.dialed = true
dialed = true
last = i
active++
} }
nextDial = nextDial[next:] nextDial = nil
if !dialed || len(nextDial) == 0 { triggerDial = nil
// we didn't dial anything because of backoff or we don't have any more addresses
triggerDial = nil
}
case res := <-resch: case res := <-resch:
active-- active--
...@@ -624,27 +604,6 @@ func (s *Swarm) dialNextAddr(ctx context.Context, p peer.ID, addr ma.Multiaddr, ...@@ -624,27 +604,6 @@ func (s *Swarm) dialNextAddr(ctx context.Context, p peer.ID, addr ma.Multiaddr,
return nil return nil
} }
func (s *Swarm) sameAddrBatch(a, b ma.Multiaddr) bool {
// is it a relay addr?
if s.IsRelayAddr(a) {
return s.IsRelayAddr(b)
}
// is it an expensive addr?
if s.IsExpensiveAddr(a) {
return s.IsExpensiveAddr(b)
}
// is it a public addr?
if !manet.IsPrivateAddr(a) {
return !manet.IsPrivateAddr(b) &&
s.IsFdConsumingAddr(a) == s.IsFdConsumingAddr(b)
}
// it's a private addr
return manet.IsPrivateAddr(b)
}
func (s *Swarm) canDial(addr ma.Multiaddr) bool { func (s *Swarm) canDial(addr ma.Multiaddr) bool {
t := s.TransportForDialing(addr) t := s.TransportForDialing(addr)
return t != nil && t.CanDial(addr) return t != nil && t.CanDial(addr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment