Opened 7 years ago

Closed 7 years ago

#6175 closed enhancement (fixed)

BridgeDB learns to choose a reasonable number of bridges to give out

Reported by: aagbsn Owned by: aagbsn
Priority: Medium Milestone:
Component: Circumvention/BridgeDB Version:
Severity: Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

BridgeDB should learn to give out a variable number of bridges based on the number of bridges available.

For example, if a user requests bridges with transport foo, and there are only 20 bridges with this transport, BridgeDB could choose to give out 1 bridge. If there are 21-100 bridges available, give out 2, and more than 100: 3 bridges (or the distributor maximum)

e.g.

if len(ring) < 20: n_bridges_per_answer = 1
if 20 < len(ring) < 100: n_bridges_per_answer = min(2,DISTRIBUTOR_N_BRIDGES_PER_ANSWER)
if len(ring) > 100: n_bridges_per_answer = DISTRIBUTOR_N_BRIDGES_PER_ANSWER

Or, BridgeDB could choose to avoid giving out more than 5 percent of bridges at a time; and return a minimum of 1 bridge and maximum of the configured DISTRIBUTOR_N_BRIDGES_PER_ANSWER

e.g.

n_bridges_per_answer =  min(min(len(ring) * .05,1),DISTRIBUTOR_N_BRIDGES_PER_ANSWER)

Child Tickets

Change History (7)

comment:1 Changed 7 years ago by aagbsn

diff --git a/lib/bridgedb/Dist.py b/lib/bridgedb/Dist.py
index ec13fb5..31cfcca 100644
--- a/lib/bridgedb/Dist.py
+++ b/lib/bridgedb/Dist.py
@@ -187,7 +187,10 @@ class IPBasedDistributor(bridgedb.Bridges.BridgeHolder):
                                   populate_from=self.splitter.bridges)
 
         # get the bridge.
-        return ring.getBridges(pos, N)
+        # determine an appropriate number of bridges
+        # XXX: assumes that N is the distributor configured maximum
+        bridges_per_answer = min(min(len(ring) * .05, 1), N)
+        return ring.getBridges(pos, bridges_per_answer)
 
     def __len__(self):
         return len(self.splitter)
@@ -389,7 +392,9 @@ class EmailBasedDistributor(bridgedb.Bridges.BridgeHolder):
                                   filterBridgesByRules(bridgeFilterRules),
                                   populate_from=self.splitter.bridges)
 
-        result = ring.getBridges(pos, N)
+        # XXX: assumes that N is the distributor configured maximum
+        bridges_per_answer = min(min(len(ring) * .05, 1), N)
+        result = ring.getBridges(pos, bridges_per_answer)
 
         db.setEmailTime(emailaddress, now)
         db.commit()

comment:2 Changed 7 years ago by rransom

Status: newneeds_revision

Put the calculation in a separate function. And in Git.

And set the ticket to needs_review.

comment:4 Changed 7 years ago by rransom

Reviewers don't want a link to the tree. They want a link to the shortlog, and for a gigantic branch name like that, a copy which they can copy-and-paste onto a Git pull command line is also quite handy.

6175-choose-reasonable-number-of-bridges ( https://git.torproject.org/user/aagbsn/bridgedb.git 6175-choose-reasonable-number-of-bridges )

comment:5 Changed 7 years ago by rransom

You also switched to the other formula; that's worth pointing out in a Trac comment so people at least know what happened.

Looks good.

comment:6 in reply to:  5 Changed 7 years ago by aagbsn

Replying to rransom:

You also switched to the other formula; that's worth pointing out in a Trac comment so people at least know what happened.

I switched to the other formula; it's easier to read, performs better, and actually works.

Looks good.

Thanks for looking.

--Aaron

comment:7 Changed 7 years ago by aagbsn

Resolution: fixed
Status: needs_reviewclosed
Note: See TracTickets for help on using tickets.