File tree 1 file changed +6
-6
lines changed
mullvad-relay-selector/src/relay_selector
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -958,10 +958,8 @@ impl RelaySelector {
958
958
relays : Vec < Relay > ,
959
959
location : T ,
960
960
) -> 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 ;
965
963
let location = location. into ( ) ;
966
964
967
965
#[ derive( Clone ) ]
@@ -979,7 +977,6 @@ impl RelaySelector {
979
977
} )
980
978
. sorted_unstable_by_key ( |relay| relay. distance as usize )
981
979
. take ( MIN_BRIDGE_COUNT )
982
- . filter ( |relay| relay. distance <= MAX_BRIDGE_DISTANCE )
983
980
. collect ( ) ;
984
981
985
982
// Calculate the maximum distance from `location` among the candidates.
@@ -988,7 +985,10 @@ impl RelaySelector {
988
985
. map ( |relay| relay. distance )
989
986
. reduce ( f64:: max) ?;
990
987
// 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 ;
992
992
993
993
helpers:: pick_random_relay_weighted ( & matching_relays, weight_fn)
994
994
. cloned ( )
You can’t perform that action at this time.
0 commit comments