/// <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); }
private void SetPeerBitfield(PeerConnection peer, Bitfield bitfield) { peer.Available = bitfield; }
private bool IsBitfieldInteresting(IMessageReceivedContext context, Bitfield bitfield) { var clientBitfield = new Bitfield(context.Metainfo.Pieces.Count, context.DataHandler.CompletedPieces); return(Bitfield.NotSubset(bitfield, clientBitfield)); }
private void SetPeerBitfield(BitTorrentPeer peer, Bitfield bitfield) { peer.Available = bitfield; }