|
@@ -296,15 +296,13 @@ class RelayPicker:
|
|
|
def pick_weighted_relay(self):
|
|
|
"""Select a random relay with probability proportional to its bw
|
|
|
weight."""
|
|
|
- totbw = self.totbw
|
|
|
- if totbw < 1:
|
|
|
- raise ValueError("No relays to choose from")
|
|
|
- idx = random.randint(0, totbw-1)
|
|
|
+ idx = self.pick_weighted_relay_index()
|
|
|
return self.pick_relay_by_uniform_index(idx)
|
|
|
|
|
|
def pick_weighted_relay_index(self):
|
|
|
- """Select a random relay index (for use in Walkig Onions) with probability proportional to its bw
|
|
|
- weight."""
|
|
|
+ """Select a random relay index (for use in Walking Onions)
|
|
|
+ uniformly, which will results in picking a relay with
|
|
|
+ probability proportional to its bw weight."""
|
|
|
totbw = self.totbw
|
|
|
if totbw < 1:
|
|
|
raise ValueError("No relays to choose from")
|