[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Constify the unrealistic maximum number of bridges per bucket
commit b778f85304ace66d1b5dbdcacc781420a71d8201
Author: Matthew Finkel <Matthew.Finkel@xxxxxxxxx>
Date: Wed Aug 20 05:51:08 2014 +0000
Constify the unrealistic maximum number of bridges per bucket
We will never, ever have 1 million bridges, but because of this we
will also never be able to satisfy the requirement of giving a bucket
one million bridges. So, when we try distributing the bridges evenly
between buckets, the pseudo-distributors that are defined as needing
'*' bridges will receive as many as are available to be allocated to
them.
---
lib/bridgedb/Bucket.py | 6 ++++--
lib/bridgedb/test/test_Bucket.py | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/bridgedb/Bucket.py b/lib/bridgedb/Bucket.py
index a7d3706..e603fe0 100644
--- a/lib/bridgedb/Bucket.py
+++ b/lib/bridgedb/Bucket.py
@@ -37,6 +37,9 @@ toHex = binascii.b2a_hex
# distinguish them from real distributors?
PSEUDO_DISTRI_PREFIX = "pseudo_"
+# Set to rediculously high number
+BUCKET_MAX_BRIDGES = 1000000
+
class BucketData:
"""A file bucket value class.
name - Name of the bucket (From config), prefixed by pseudo
@@ -47,8 +50,7 @@ class BucketData:
def __init__(self, name, needed):
self.name = name
if needed == "*":
- # Set to rediculously high number
- needed = 1000000
+ needed = BUCKET_MAX_BRIDGES
self.needed = int(needed)
self.allocated = 0
diff --git a/lib/bridgedb/test/test_Bucket.py b/lib/bridgedb/test/test_Bucket.py
index 7cadd7b..8893dcd 100644
--- a/lib/bridgedb/test/test_Bucket.py
+++ b/lib/bridgedb/test/test_Bucket.py
@@ -39,7 +39,7 @@ class BucketDataTest(unittest.TestCase):
distname = "test-distributor"
bucket = Bucket.BucketData(distname, alloc)
this(distname).should.be.equal(bucket.name)
- this(alloc).should.be.equal(1000000)
+ this(Bucket.BUCKET_MAX_BRIDGES).should.be.equal(bucket.needed)
class BucketManagerTest(unittest.TestCase):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits