Author: alanmc
Date: 2006-09-17 10:21:31 -0400 (Sun, 17 Sep 2006)
New Revision: 65548

Modified:
   trunk/bitsharp/src/MonoTorrent.Client/Managers/PieceManager.cs
Log:
Will now choose a SuggestedPiece above a normal piece

Modified: trunk/bitsharp/src/MonoTorrent.Client/Managers/PieceManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent.Client/Managers/PieceManager.cs      
2006-09-17 14:14:09 UTC (rev 65547)
+++ trunk/bitsharp/src/MonoTorrent.Client/Managers/PieceManager.cs      
2006-09-17 14:21:31 UTC (rev 65548)
@@ -97,6 +97,23 @@
             lock (this.bufferField)
             {
                 Piece piece;
+
+                if (id.Peer.Connection.SuggestedPieces.Count > 0)
+                {
+                    
while(this.mybitField[id.Peer.Connection.SuggestedPieces[0]]
+                        && id.Peer.Connection.SuggestedPieces.Count > 0)
+                        id.Peer.Connection.SuggestedPieces.RemoveAt(0);
+
+                    if (id.Peer.Connection.SuggestedPieces.Count != 0)
+                    {
+                        piece = new 
Piece(id.Peer.Connection.SuggestedPieces[0], id.TorrentManager.Torrent);
+                        piece[0].Requested = true;
+                        this.mybitField[id.Peer.Connection.SuggestedPieces[0]] 
= true;  // Flag this one as downloaded. If it hashfails, remove it
+                        this.requests.Add(id, piece);
+                        id.Peer.Connection.SuggestedPieces.RemoveAt(0);
+                        return piece[0].CreateRequest();
+                    }
+                }
                 lock (this.mybitField)
                     Array.Copy(this.mybitField.Array, 0, bufferField.Array, 0, 
this.mybitField.Array.Length);
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to