From 71cec86bf78211f2ba79ef42bf0fff5e61ffa1f4 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 9 Aug 2026 09:12:47 -0400 Subject: [PATCH] don't connect to peers and set numwant to 0 when seeding --- libi2pd_client/Torrents.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index a5e6ea7c..a73299d6 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -838,6 +838,8 @@ namespace torrents } if (isInterested) SendInterestedMsg (); + else if (m_RemoteBitfield.all ()) // remote is seeding + Terminate (); // we don't need this connection } void PeerConnection::SendBitfieldMsg (const uint8_t * bitfield, size_t bitfieldLen) @@ -1257,7 +1259,7 @@ namespace torrents params.emplace ("uploaded", "0"); // TODO params.emplace ("downloaded", "0"); // TODO params.emplace ("left", "1"); // TODO - params.emplace ("numwant", "25"); // max num of peers, 0 if seeding + params.emplace ("numwant", torrent->IsComplete () ? "0" : "25"); // max num of peers, 0 if seeding reqURL.create_query (params); auto req = std::make_shared >(boost::beast::http::verb::get, reqURL.to_string (true), 11); // HTTP 1.1 @@ -1398,9 +1400,12 @@ namespace torrents { for (auto it: m_Torrents) { - auto numPeers = ConnectToPeers (it.second); - if (numPeers) - LogPrint (eLogDebug, "Torrents: Reconnecting to ", numPeers, " peers"); + if (!it.second->IsComplete ()) + { + auto numPeers = ConnectToPeers (it.second); + if (numPeers) + LogPrint (eLogDebug, "Torrents: Reconnecting to ", numPeers, " peers"); + } } ScheduleReconnectCheck (); }