mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-06 14:18:27 +00:00
don't connect to peers for complete torrent
This commit is contained in:
@@ -2311,6 +2311,7 @@ namespace torrents
|
||||
|
||||
void PeerConnection::HandleI2PPEXExtension (const uint8_t * buf, size_t len)
|
||||
{
|
||||
if (m_Torrent->IsComplete ()) return;
|
||||
std::unordered_set<i2p::data::IdentHash> newPeers;
|
||||
ParseDictionary (std::string_view ((const char *)buf, len),
|
||||
[&newPeers](std::string_view key, std::string_view buf)->size_t
|
||||
|
||||
@@ -857,14 +857,17 @@ namespace torrents
|
||||
auto torrent = info ? info->torrent.lock () : nullptr;
|
||||
if (torrent)
|
||||
{
|
||||
std::unordered_set<i2p::data::IdentHash> newPeers;
|
||||
for (auto it: peers)
|
||||
if (it.size () == i2p::data::IdentHash::len)
|
||||
newPeers.emplace ((const uint8_t *)it.data ());
|
||||
if (!newPeers.empty ())
|
||||
if (!torrent->IsComplete ())
|
||||
{
|
||||
LogPrint (eLogDebug, "TorrentsDHT: ", newPeers.size (), " new peers received");
|
||||
m_Tunnel.ConnectToNewPeers (torrent, newPeers, ePeerConnectionOriginDHT);
|
||||
std::unordered_set<i2p::data::IdentHash> newPeers;
|
||||
for (auto it: peers)
|
||||
if (it.size () == i2p::data::IdentHash::len)
|
||||
newPeers.emplace ((const uint8_t *)it.data ());
|
||||
if (!newPeers.empty ())
|
||||
{
|
||||
LogPrint (eLogDebug, "TorrentsDHT: ", newPeers.size (), " new peers received");
|
||||
m_Tunnel.ConnectToNewPeers (torrent, newPeers, ePeerConnectionOriginDHT);
|
||||
}
|
||||
}
|
||||
LogPrint (eLogDebug, "TorrentsDHT: Send announce to ", toIdent.ToBase64 ());
|
||||
SendAnnouncePeerQuery (torrent->GetInfoHash (), token, toIdent, toPort);
|
||||
|
||||
@@ -706,7 +706,7 @@ namespace torrents
|
||||
|
||||
size_t TorrentsTunnel::ConnectToPeers (std::shared_ptr<Torrent> torrent)
|
||||
{
|
||||
if (!torrent) return 0;
|
||||
if (!torrent || torrent->IsComplete ()) return 0;
|
||||
auto peersToConnect = torrent->GetNonConnectedPeers (); // from trackers
|
||||
if (!peersToConnect.empty ())
|
||||
{
|
||||
@@ -718,7 +718,7 @@ namespace torrents
|
||||
|
||||
size_t TorrentsTunnel::ConnectToPeers (std::shared_ptr<Torrent> torrent, size_t trackerID)
|
||||
{
|
||||
if (!torrent) return 0;
|
||||
if (!torrent || torrent->IsComplete ()) return 0;
|
||||
auto peersToConnect = torrent->GetNonConnectedPeers (trackerID);
|
||||
if (!peersToConnect.empty ())
|
||||
{
|
||||
@@ -731,7 +731,7 @@ namespace torrents
|
||||
void TorrentsTunnel::ConnectToNewPeers (std::shared_ptr<Torrent> torrent,
|
||||
std::unordered_set<i2p::data::IdentHash>& newPeers, PeerConnectionOrigin origin)
|
||||
{
|
||||
if (!torrent) return;
|
||||
if (!torrent || torrent->IsComplete ()) return;
|
||||
if (!newPeers.empty ())
|
||||
{
|
||||
for (const auto& it: newPeers)
|
||||
|
||||
Reference in New Issue
Block a user