2
0
mirror of synced 2025-02-24 14:48:27 +00:00

Count peers added from DHT for logging

This commit is contained in:
Matt Joiner 2021-05-24 18:08:32 +10:00
parent d7c549d2e4
commit f5d2ba37bc

View File

@ -1538,17 +1538,23 @@ func (t *Torrent) consumeDhtAnnouncePeers(pvs <-chan dht.PeersValues) {
cl := t.cl cl := t.cl
for v := range pvs { for v := range pvs {
cl.lock() cl.lock()
added := 0
for _, cp := range v.Peers { for _, cp := range v.Peers {
if cp.Port == 0 { if cp.Port == 0 {
// Can't do anything with this. // Can't do anything with this.
continue continue
} }
t.addPeer(PeerInfo{ if t.addPeer(PeerInfo{
Addr: ipPortAddr{cp.IP, cp.Port}, Addr: ipPortAddr{cp.IP, cp.Port},
Source: PeerSourceDhtGetPeers, Source: PeerSourceDhtGetPeers,
}) }) {
added++
}
} }
cl.unlock() cl.unlock()
if added != 0 {
//log.Printf("added %v peers from dht for %v", added, t.InfoHash().HexString())
}
} }
} }