예제 #1
0
        /// <summary>
        /// Determines whether Bitfield a has pieces not available in Bitfield b.
        /// </summary>
        /// <param name="a">Bitfield to check for more pieces in.</param>
        /// <param name="b">Bitfield to compare against.</param>
        /// <returns>True if a has more pieces </returns>
        public static bool NotSubset(Bitfield a, Bitfield b)
        {
            for (int i = 0; i < a.Length; i++)
            {
                if (a.IsPieceAvailable(i) && !b.IsPieceAvailable(i))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
 private void SetPeerBitfield(PeerConnection peer, Bitfield bitfield)
 {
     peer.Available = bitfield;
 }
예제 #3
0
        private bool IsBitfieldInteresting(IMessageReceivedContext context, Bitfield bitfield)
        {
            var clientBitfield = new Bitfield(context.Metainfo.Pieces.Count, context.DataHandler.CompletedPieces);

            return(Bitfield.NotSubset(bitfield, clientBitfield));
        }
예제 #4
0
 private void SetPeerBitfield(BitTorrentPeer peer, Bitfield bitfield)
 {
     peer.Available = bitfield;
 }