1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-22 07:42:37 +00:00

refactor: improve criteria for choosing peers to save to resume (#6922)

* fix: only consider peers with listening ports interesting

It's a waste of space to store peers we cannot connect to (because we don't know what their listening port is).

* fix: don't consider peer as interesting just because we are currently connected to it

For example, it's possible for a peer to be "in-use" and "banned" at the same time, albeit just for a very short while.

* code review: assert that peer port is not empty
This commit is contained in:
Yat Ho 2024-10-14 02:48:49 +08:00 committed by GitHub
parent 4db50dae10
commit 21d7720749
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1465,14 +1465,15 @@ namespace get_peers_helpers
[[nodiscard]] bool is_peer_interesting(tr_torrent const* tor, tr_peer_info const& info)
{
if (tor->is_done() && info.is_upload_only())
TR_ASSERT(!std::empty(info.listen_port()));
if (std::empty(info.listen_port()))
{
return false;
}
if (info.is_in_use())
if (tor->is_done() && info.is_upload_only())
{
return true;
return false;
}
if (info.is_blocklisted(tor->session->blocklist()))