public Request(PeerId peer, Block block) { Peer = peer; Block = block; }
private bool AlreadyRequested(Block block, PeerId id) { bool b = requests.Exists(delegate(Request r) { return r.Block.PieceIndex == block.PieceIndex && r.Block.StartOffset == block.StartOffset && r.Peer == id; }); return b; }
private void Init(Block block, Piece piece, PeerId id) { this.block = block; this.id = id; this.piece = piece; }
internal static int IndexOf(Block[] blocks, int startOffset, int blockLength) { int index = startOffset/Piece.BlockSize; if (blocks[index].startOffset != startOffset || blocks[index].RequestLength != blockLength) return -1; return index; }
/// <summary> /// Creates a new PeerMessageEventArgs /// </summary> /// <param name="message">The peer message involved</param> /// <param name="direction">The direction of the message</param> internal BlockEventArgs(TorrentManager manager, Block block, Piece piece, PeerId id) : base(manager) { Init(block, piece, id); }