]> Sergey Matveev's repositories - btrtrc.git/commitdiff
dht: Slow down the start a little, as lots of torrents will hammer out UDP packets
authorMatt Joiner <anacrolix@gmail.com>
Tue, 9 Dec 2014 06:24:05 +0000 (00:24 -0600)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 9 Dec 2014 06:24:05 +0000 (00:24 -0600)
dht/getpeers.go

index 39ea266f388d98834c65168e7d86d6361d7a0766..b3ecbe64349321cb3003071d5180ee1e88f4886e 100644 (file)
@@ -4,6 +4,7 @@ import (
        "log"
        "net"
        "sync"
+       "time"
 
        "bitbucket.org/anacrolix/go.torrent/util"
 )
@@ -70,7 +71,10 @@ func (s *Server) GetPeers(infoHash string) (*peerStream, error) {
                }
        }()
        disc.mu.Lock()
-       for _, addr := range startAddrs {
+       for i, addr := range startAddrs {
+               if i != 0 {
+                       time.Sleep(time.Millisecond)
+               }
                disc.contact(addr)
        }
        disc.mu.Unlock()