Skip to content

Commit 6760a98

Browse files
Consider the closest 10 bridges
1 parent e859f00 commit 6760a98

File tree

1 file changed

+6
-6
lines changed
  • mullvad-relay-selector/src/relay_selector

1 file changed

+6
-6
lines changed

mullvad-relay-selector/src/relay_selector/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,8 @@ impl RelaySelector {
958958
relays: Vec<Relay>,
959959
location: T,
960960
) -> Option<Relay> {
961-
/// Minimum number of bridges to keep for selection when filtering by distance.
962-
const MIN_BRIDGE_COUNT: usize = 5;
963-
/// Max distance of bridges to consider for selection (km).
964-
const MAX_BRIDGE_DISTANCE: f64 = 1500f64;
961+
/// Minimum number of bridges to keep for selection by distance.
962+
const MIN_BRIDGE_COUNT: usize = 10;
965963
let location = location.into();
966964

967965
#[derive(Clone)]
@@ -979,7 +977,6 @@ impl RelaySelector {
979977
})
980978
.sorted_unstable_by_key(|relay| relay.distance as usize)
981979
.take(MIN_BRIDGE_COUNT)
982-
.filter(|relay| relay.distance <= MAX_BRIDGE_DISTANCE)
983980
.collect();
984981

985982
// Calculate the maximum distance from `location` among the candidates.
@@ -988,7 +985,10 @@ impl RelaySelector {
988985
.map(|relay| relay.distance)
989986
.reduce(f64::max)?;
990987
// Define the weight function to prioritize bridges which are closer to `location`.
991-
let weight_fn = |relay: &RelayWithDistance| 1 + (greatest_distance - relay.distance) as u64;
988+
// TODO(markus): Finish this document
989+
// Penalize bridges ..
990+
let weight_fn =
991+
|relay: &RelayWithDistance| 1 + (greatest_distance - relay.distance).powi(2) as u64;
992992

993993
helpers::pick_random_relay_weighted(&matching_relays, weight_fn)
994994
.cloned()

0 commit comments

Comments
 (0)