]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Set a new peer's ranking values so they don't get an unfair advantage.
authorCameron Dale <camrdale@gmail.com>
Fri, 9 May 2008 21:51:09 +0000 (14:51 -0700)
committerCameron Dale <camrdale@gmail.com>
Fri, 9 May 2008 21:51:09 +0000 (14:51 -0700)
apt_p2p/HTTPDownloader.py

index 3e6eaa3916eee36e782f778a777c3a4bb129e6fc..8ecac193f6cba22c71ac1747d5df89d327a4ea4f 100644 (file)
@@ -377,7 +377,7 @@ class Peer(ClientFactory):
 
         # If there are none, then you get 0
         if not self._downloadSpeeds:
-            return 0.0
+            return 150000.0
         
         for download in self._downloadSpeeds:
             total_time += download[1].days*86400.0 + download[1].seconds + download[1].microseconds/1000000.0
@@ -400,7 +400,7 @@ class Peer(ClientFactory):
 
         # If there are none, give it the benefit of the doubt
         if not self._responseTimes:
-            return 0.0
+            return 0.1
 
         for response in self._responseTimes:
             total_response += response[1].days*86400.0 + response[1].seconds + response[1].microseconds/1000000.0
@@ -594,7 +594,7 @@ class TestClientManager(unittest.TestCase):
         from twisted.internet.error import DNSLookupError
         host = 'hureyfnvbfha.debian.net'
         self.client = Peer(host, 80)
-        self.timeout = 10
+        self.timeout = 5
         
         d = self.client.get('/rfc/rfc0013.txt')
         d.addCallback(self.gotResp, 1, 1070)
@@ -607,7 +607,7 @@ class TestClientManager(unittest.TestCase):
         from twisted.internet.error import NoRouteError
         host = '1.2.3.4'
         self.client = Peer(host, 80)
-        self.timeout = 60
+        self.timeout = 5
         
         d = self.client.get('/rfc/rfc0013.txt')
         d.addCallback(self.gotResp, 1, 1070)