OctoTorrent.Client.ChokeUnchokeManager.RejectPendingRequests C# (CSharp) Method

RejectPendingRequests() private method

Checks the send queue of the peer to see if there are any outstanding pieces which they requested and rejects them as necessary
private RejectPendingRequests ( PeerId Peer ) : void
Peer PeerId
return void
        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));
                }
            }
        }