[tor-commits] [sbws/master] Stop removing results that are not away

pastly at torproject.org pastly at torproject.org
Mon Oct 22 13:44:07 UTC 2018


commit 39c5e42a3517ea9d7732f2b01615d368f7b3bc3c
Author: juga0 <juga at riseup.net>
Date:   Thu Oct 18 11:26:52 2018 +0000

    Stop removing results that are not away
    
    from some other X secs.
    In #27338 it was implemented to do not include relays in the
    bandwidth files that does not have at least 2 measurements that
    are X secs away from each other.
    It was implemented removing any results that were not X secs away
    from each other, when all the results should be keep when there is
    at least one away from the others, as commented in #28061.
---
 sbws/lib/v3bwfile.py | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index 4eecda6..ced0c20 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -5,6 +5,7 @@
 import copy
 import logging
 import os
+from itertools import combinations
 from statistics import median, mean
 
 from sbws import __version__
@@ -332,17 +333,12 @@ class V3BWLine(object):
         #           "secs.", secs_away)
         if secs_away is None or len(results) < 2:
             return results
-        # the last one should be the most recent
-        results_away = [results[-1]]
-        # iterate over the rest of the results in reverse order
-        for r in reversed(results[:-1]):
-            if abs(results_away[0].time - r.time) > secs_away:
-                results_away.insert(0, r)
-        # if there is only 1 result, is the one inserted at the beginning,
-        # so there are no results away from each other
-        if len(results_away) < 2:
-            return None
-        return results_away
+        for a, b in combinations(results, 2):
+            if abs(a.time - b.time) > secs_away:
+                return results
+        # log.debug("Results are NOT away from each other in at least %ss: %s",
+        #           secs_away, [unixts_to_isodt_str(r.time) for r in results])
+        return None
 
     @staticmethod
     def results_recent_than(results, secs_recent=None):





More information about the tor-commits mailing list