From df3877563061a62a9b467c063938d872b6f1fb65 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 14 Apr 2018 21:44:41 +1000 Subject: [PATCH] A few adjustments to prioritized peers usage --- client.go | 2 +- torrent.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index a07e3dac..8985e1a0 100644 --- a/client.go +++ b/client.go @@ -943,7 +943,7 @@ func (cl *Client) newTorrent(ih metainfo.Hash, specStorage storage.ClientImpl) ( cl: cl, infoHash: ih, peers: prioritizedPeers{ - om: btree.New(2), + om: btree.New(32), getPrio: func(p Peer) peerPriority { return bep40PriorityIgnoreError(cl.publicAddr(p.IP), p.addr()) }, diff --git a/torrent.go b/torrent.go index bc3f2a08..4a784300 100644 --- a/torrent.go +++ b/torrent.go @@ -258,8 +258,10 @@ func (t *Torrent) addPeer(p Peer) { } t.openNewConns() for t.peers.Len() > cl.config.TorrentPeersHighWater { - t.peers.DeleteMin() - torrent.Add("peers discarded", 1) + _, ok := t.peers.DeleteMin() + if ok { + torrent.Add("excess reserve peers discarded", 1) + } } }