A few adjustments to prioritized peers usage

This commit is contained in:
Matt Joiner 2018-04-14 21:44:41 +10:00
parent cefcda18c6
commit df38775630
2 changed files with 5 additions and 3 deletions

View File

@ -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())
},

View File

@ -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)
}
}
}