[tor-commits] [sbws/master] relayprioritizer: remove asserts on hard-coded values

juga at torproject.org juga at torproject.org
Fri Feb 15 17:51:28 UTC 2019


commit ce08884f51b500d2dabaedf371dc2bf53bee0297
Author: juga0 <juga at riseup.net>
Date:   Tue Dec 18 09:07:47 2018 +0000

    relayprioritizer: remove asserts on hard-coded values
    
    result.freshness_reduction_factor are hard-coded values, no need
    to assert.
---
 sbws/lib/relayprioritizer.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sbws/lib/relayprioritizer.py b/sbws/lib/relayprioritizer.py
index 318d1a8..9c065a7 100644
--- a/sbws/lib/relayprioritizer.py
+++ b/sbws/lib/relayprioritizer.py
@@ -82,15 +82,15 @@ class RelayPrioritizer:
                 freshness = result.time - oldest_allowed
                 if isinstance(result, ResultError) \
                     and prioritize_result_error is True:
-                    # Reduce the freshness for results containing errors so
-                    # that they are not de-prioritized as much. This way, we
-                    # will come back to them sooner to try again.
-                    assert result.freshness_reduction_factor >= 0.0
-                    assert result.freshness_reduction_factor <= 1.0
                     log.debug('Cutting freshness for a %s result by %d%% for '
                               '%s', result.type.value,
                               result.freshness_reduction_factor * 100,
                               relay.nickname)
+                    # result.freshness_reduction_factor are hard-coded values
+                    # on how much prioritize measurements that failed
+                    # depending on the type of error.
+                    # In a future refactor, create these values on an algorithm
+                    # or create constants.
                     freshness *= max(1.0-result.freshness_reduction_factor, 0)
                 priority += freshness
             relay.priority = priority





More information about the tor-commits mailing list