Exemple #1
0
 public Request(PeerId peer, Block block)
 {
     Peer = peer;
     Block = block;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 private void Init(Block block, Piece piece, PeerId id)
 {
     this.block = block;
     this.id = id;
     this.piece = piece;
 }
Exemple #4
0
 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;
 }
Exemple #5
0
 /// <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);
 }