mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-06 09:58:32 +00:00
handle allowed fast msg
This commit is contained in:
@@ -1192,7 +1192,7 @@ namespace torrents
|
||||
HandleRejectRequestMsg (m_ReceiveBuffer + offset + 1, msgLen - 1);
|
||||
break;
|
||||
case eMessageTypeAllowedFast:
|
||||
LogPrint (eLogDebug, "Torrents: allowed fast msg received");
|
||||
HandleAllowedFastMsg (m_ReceiveBuffer + offset + 1, msgLen - 1);
|
||||
break;
|
||||
default:
|
||||
LogPrint (eLogWarning, "Torrents: Unexpected message type ", (int)m_ReceiveBuffer[offset], ". Ignored");
|
||||
@@ -1705,6 +1705,23 @@ namespace torrents
|
||||
m_SuggestedPieceIndex = index;
|
||||
}
|
||||
|
||||
void PeerConnection::HandleAllowedFastMsg (const uint8_t * buf, size_t len)
|
||||
{
|
||||
if (len < 4 || !m_Torrent) return;
|
||||
uint32_t index = bufbe32toh (buf);
|
||||
LogPrint (eLogDebug, "Torrents: allowed fast msg received");
|
||||
if (m_IsChoked && index < m_Torrent->GetNumPieces ())
|
||||
{
|
||||
Piece& piece = m_Torrent->GetPiece (index);
|
||||
if (!piece.IsComplete () && !piece.IsRequested ())
|
||||
{
|
||||
uint32_t offset = 0, len = 0;
|
||||
while (std::tie (offset, len) = piece.GetNextBlockToRequest (), len > 0)
|
||||
SendRequestedBlock ({index, offset, len});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PeerConnection::HandleExtendedMsg (const uint8_t * buf, size_t len)
|
||||
{
|
||||
if (len < 1) return;
|
||||
|
||||
@@ -341,6 +341,7 @@ namespace torrents
|
||||
void SendChokeMsg ();
|
||||
void HandleChokeMsg ();
|
||||
void HandleSuggestPieceMsg (const uint8_t * buf, size_t len);
|
||||
void HandleAllowedFastMsg (const uint8_t * buf, size_t len);
|
||||
void HandleExtendedMsg (const uint8_t * buf, size_t len);
|
||||
void SendExtendedMsg (uint8_t extendedMsgID = 0, std::string_view payload = "", std::string_view data = "");
|
||||
void AddExtendedMsgHandler (std::string_view extensionName, int64_t msgID);
|
||||
|
||||
Reference in New Issue
Block a user