Adjust recently added logging
This commit is contained in:
parent
730cebf5aa
commit
070e11a0dd
9
Peer.go
9
Peer.go
@ -20,6 +20,15 @@ type Peer struct {
|
||||
Trusted bool
|
||||
}
|
||||
|
||||
func (me Peer) Equal(other Peer) bool {
|
||||
return me.Id == other.Id &&
|
||||
me.Addr.String() == other.Addr.String() &&
|
||||
me.Source == other.Source &&
|
||||
me.SupportsEncryption == other.SupportsEncryption &&
|
||||
me.PexPeerFlags == other.PexPeerFlags &&
|
||||
me.Trusted == other.Trusted
|
||||
}
|
||||
|
||||
// FromPex generate Peer from peer exchange
|
||||
func (me *Peer) FromPex(na krpc.NodeAddr, fs peer_protocol.PexPeerFlags) {
|
||||
me.Addr = ipPortAddr{append([]byte(nil), na.IP...), na.Port}
|
||||
|
@ -269,7 +269,9 @@ func (t *Torrent) addPeer(p Peer) {
|
||||
}
|
||||
if replaced, ok := t.peers.AddReturningReplacedPeer(p); ok {
|
||||
torrent.Add("peers replaced", 1)
|
||||
t.logger.Printf("added %v replacing %v", p, replaced)
|
||||
if !replaced.Equal(p) {
|
||||
t.logger.Printf("added %v replacing %v", p, replaced)
|
||||
}
|
||||
}
|
||||
t.openNewConns()
|
||||
for t.peers.Len() > cl.config.TorrentPeersHighWater {
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/dht/v2/krpc"
|
||||
"github.com/anacrolix/log"
|
||||
|
||||
"github.com/anacrolix/torrent/tracker"
|
||||
)
|
||||
@ -116,7 +117,7 @@ func (me *trackerScraper) announce(event tracker.AnnounceEvent) (ret trackerAnno
|
||||
me.t.cl.rLock()
|
||||
req := me.t.announceRequest(event)
|
||||
me.t.cl.rUnlock()
|
||||
me.t.logger.Printf("announcing to %q: %#v", me.u.String(), req)
|
||||
me.t.logger.WithValues(log.Debug).Printf("announcing to %q: %#v", me.u.String(), req)
|
||||
res, err := tracker.Announce{
|
||||
HTTPProxy: me.t.cl.config.HTTPProxy,
|
||||
UserAgent: me.t.cl.config.HTTPUserAgent,
|
||||
|
Loading…
x
Reference in New Issue
Block a user