[tor-commits] [sbws/master] v3bwfile, resultdump: support results without new bw

juga at torproject.org juga at torproject.org
Mon Dec 3 21:27:35 UTC 2018


commit 54afe75307dfbe6256f4307c080b82e354737317
Author: juga0 <juga at riseup.net>
Date:   Mon Dec 3 20:58:23 2018 +0000

    v3bwfile, resultdump: support results without new bw
    
    When parsing results support old ones without new bandwidth
    attributes, as descriptor bandwidth burst, consensus_bandwidth
    and consensus bandwidth is unmeasured.
---
 sbws/core/generate.py  |  2 +-
 sbws/lib/resultdump.py |  6 +++---
 sbws/lib/v3bwfile.py   | 11 +++++++++--
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/sbws/core/generate.py b/sbws/core/generate.py
index f9b46cb..283a71f 100644
--- a/sbws/core/generate.py
+++ b/sbws/core/generate.py
@@ -54,7 +54,7 @@ def gen_parser(sub):
     p.add_argument('-m', '--torflow-bw-margin', default=TORFLOW_BW_MARGIN,
                    type=float,
                    help="Cap maximum bw when scaling as Torflow. ")
-    p.add_argument('-r', '--round-digs', '--torflow-round-digs',
+    p.add_argument('-r', '--torflow-round-digs',
                    default=PROP276_ROUND_DIG, type=int,
                    help="Number of most significant digits to round bw.")
     p.add_argument('-p', '--secs-recent', default=None, type=int,
diff --git a/sbws/lib/resultdump.py b/sbws/lib/resultdump.py
index 0f7e1af..3756f6f 100644
--- a/sbws/lib/resultdump.py
+++ b/sbws/lib/resultdump.py
@@ -501,9 +501,9 @@ class ResultSuccess(Result):
             Result.Relay(
                 d['fingerprint'], d['nickname'], d['address'],
                 d['master_key_ed25519'], d['relay_average_bandwidth'],
-                d['relay_burst_bandwidth'], d['relay_observed_bandwidth'],
-                d['consensus_bandwidth'],
-                d['consensus_bandwidth_is_unmeasured']),
+                d.get('relay_burst_bandwidth'), d['relay_observed_bandwidth'],
+                d.get('consensus_bandwidth'),
+                d.get('consensus_bandwidth_is_unmeasured')),
             d['circ'], d['dest_url'], d['scanner'],
             t=d['time'])
 
diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index 55f63ec..4590812 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -848,8 +848,15 @@ class V3BWFile(object):
             # descriptors' bandwidth-observed, because that penalises new
             # relays.
             # See https://trac.torproject.org/projects/tor/ticket/8494
-            desc_bw = min(desc_bw_obs, l.desc_bw_bur, l.desc_bw_avg)
-            if l.consensus_bandwidth_is_unmeasured:
+            if l.desc_bw_bur is not None:
+                # Because in previous versions results were not storing
+                # desc_bw_bur
+                desc_bw = min(desc_bw_obs, l.desc_bw_bur, l.desc_bw_avg)
+            else:
+                desc_bw = min(desc_bw_obs, l.desc_bw_avg)
+            # In previous versions results were not storing consensus_bandwidth
+            if l.consensus_bandwidth_is_unmeasured \
+                    or l.consensus_bandwidth is None:
                 min_bandwidth = desc_bw
             # If the relay is measured, use the minimum between the descriptors
             # bandwidth and the consensus bandwidth, so that



More information about the tor-commits mailing list