private void RejectPendingRequests(PeerId Peer)
{
var length = Peer.QueueLength;
for (var i = 0; i < length; i++)
{
var message = Peer.Dequeue();
var pieceMessage = message as PieceMessage;
if (pieceMessage == null)
{
Peer.Enqueue(message);
continue;
}
// If the peer doesn't support fast peer, then we will never requeue the message
if (!(Peer.SupportsFastPeer && ClientEngine.SupportsFastPeer))
{
Peer.IsRequestingPiecesCount--;
continue;
}
// If the peer supports fast peer, queue the message if it is an AllowedFast piece
// Otherwise send a reject message for the piece
if (Peer.AmAllowedFastPieces.Contains(pieceMessage.PieceIndex))
Peer.Enqueue(pieceMessage);
else
{
Peer.IsRequestingPiecesCount--;
Peer.Enqueue(new RejectRequestMessage(pieceMessage));
}
}
}