Skip to content
This repository
Browse code

[InitialSeeding] Only choke/unchoke if there's a pending unchoke.

We don't need to choke peers if there's no-one waiting to take the
slot.
  • Loading branch information...
commit b2c6f44d2776f9c5dbe03250d14cc8be3e1139da 1 parent ed4175c
Alan McGovern authored October 13, 2010
20  src/MonoTorrent/MonoTorrent.Client/Unchokers/InitialSeedUnchoker.cs
@@ -271,15 +271,16 @@ void TryUnchoke(ChokeData data)
271 271
 
272 272
         public override void UnchokeReview()
273 273
         {
274  
-            List<ChokeData> dupePieces = new List<ChokeData>(peers);
275  
-            foreach (ChokeData data in dupePieces)
276  
-                TryChoke(data);
277  
-
278  
-            List<ChokeData> dupe = new List<ChokeData>(peers);
279  
-
280  
-            // See if there's anyone interesting to unchoke
281  
-            foreach (ChokeData data in dupe)
282  
-                TryUnchoke(data);
  274
+            if (PendingUnchoke) {
  275
+                List<ChokeData> dupePeers = new List<ChokeData>(peers);
  276
+                foreach (ChokeData data in dupePieces)
  277
+                    TryChoke(data);
  278
+
  279
+                dupePeers = new List<ChokeData>(peers);
  280
+                // See if there's anyone interesting to unchoke
  281
+                foreach (ChokeData data in dupePieces)
  282
+                    TryUnchoke(data);
  283
+            }
283 284
 
284 285
             // Make sure our list of pieces available in the swarm is up to date
285 286
             foreach (ChokeData data in peers)
@@ -290,7 +291,6 @@ public override void UnchokeReview()
290 291
             // Send have messages to anyone that needs them
291 292
             foreach (ChokeData data in peers)
292 293
                 TryAdvertisePiece(data);
293  
-
294 294
         }
295 295
     }
296 296
 }

0 notes on commit b2c6f44

Please sign in to comment.
Something went wrong with that request. Please try again.