try to request piece receive in have message

This commit is contained in:
orignal committed 2026-08-07 17:38:48 -04:00
1 parent d717209125
commit e9bc797ba8
1 file changed
+13
+13
View File
@@ -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)