From e9bc797ba86451977ecf89aab149621381bb7337 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 7 Aug 2026 17:38:48 -0400 Subject: [PATCH] try to request piece receive in have message --- libi2pd_client/Torrents.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index 30e11464..634840e5 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -760,7 +760,20 @@ namespace torrents if (len < 4) return; uint32_t index = bufbe32toh (buf); if (index < m_RemoteBitfield.size ()) + { m_RemoteBitfield.set (index); + if (m_NumRequests < MAX_NUM_REQUESTS && m_Torrent && !m_Torrent->IsComplete ()) + { + Piece& piece = m_Torrent->GetPiece (index); + if (!piece.IsComplete () && !piece.IsRequested ()) + { + // new piece that was not requested yet + auto [offset, len] = piece.GetNextBlockToRequest (); + if (len > 0) + SendRequestMsg (index, offset, len); + } + } + } } void PeerConnection::SendHaveMsg (uint32_t index)