From f5d2ba37bc9ccd2d7e18165e41408c8125be5e4b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 24 May 2021 18:08:32 +1000 Subject: [PATCH] Count peers added from DHT for logging --- torrent.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/torrent.go b/torrent.go index 18a3f758..e3876474 100644 --- a/torrent.go +++ b/torrent.go @@ -1538,17 +1538,23 @@ func (t *Torrent) consumeDhtAnnouncePeers(pvs <-chan dht.PeersValues) { cl := t.cl for v := range pvs { cl.lock() + added := 0 for _, cp := range v.Peers { if cp.Port == 0 { // Can't do anything with this. continue } - t.addPeer(PeerInfo{ + if t.addPeer(PeerInfo{ Addr: ipPortAddr{cp.IP, cp.Port}, Source: PeerSourceDhtGetPeers, - }) + }) { + added++ + } } cl.unlock() + if added != 0 { + //log.Printf("added %v peers from dht for %v", added, t.InfoHash().HexString()) + } } }