diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index f622c4f7..a6752e73 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -764,6 +764,12 @@ namespace torrents 0, 0, 0, i2p::util::GetSecondsSinceEpoch (), ""}); } + void Torrent::SetInterval (size_t trackerID, int interval) + { + CheckTrackerStatsSize (trackerID); + std::get<1>(m_TrackerStats[trackerID]) = interval; + } + std::pair, boost::logic::tribool> Torrent::CreateBitfield () const { size_t numPieces = m_Pieces.size (); diff --git a/libi2pd_client/Torrents.h b/libi2pd_client/Torrents.h index 0903642a..dabea4bd 100644 --- a/libi2pd_client/Torrents.h +++ b/libi2pd_client/Torrents.h @@ -245,6 +245,7 @@ namespace torrents size_t GetLength () const { return m_Length; } size_t GetPieceLength () const { return m_PieceLength; } int GetInterval (size_t trackerID) const { return (trackerID < m_TrackerStats.size ()) ? std::get<1>(m_TrackerStats[trackerID]) : MIN_TRACKER_REQUESTS_INTERVAL; } + void SetInterval (size_t trackerID, int interval); const std::vector GetInfo () const { return m_Info; } const InfoHash& GetInfoHash () const { return m_InfoHash; } size_t GetLeft () const; diff --git a/libi2pd_client/TorrentsTunnel.cpp b/libi2pd_client/TorrentsTunnel.cpp index 4ef485d4..4ded6f3e 100644 --- a/libi2pd_client/TorrentsTunnel.cpp +++ b/libi2pd_client/TorrentsTunnel.cpp @@ -759,7 +759,10 @@ namespace torrents if (ts >= it.second->GetNextTrackerRequestTime (i)) { if (i2p::util::GetSecondsSinceEpoch () > it.second->GetLastTrackerUpdateTime (i) + 2*it.second->GetInterval (i)/1000 && it.second->GetTrackerError (i).empty ()) + { it.second->SetTrackerError (i, "No response"); + it.second->SetInterval (i, MIN_TRACKER_REQUESTS_INTERVAL); // try again shortly + } if (RequestTracker (i, it.second, eTrackerAnnounceEventNone)) { auto nextInterval = it.second->GetInterval (i) + GetLocalDestination ()->GetRng()() % TRACKER_REQUESTS_INTERVAL_VARIANCE;