[tor-commits] [sbws/master] resultdump: store bandwidth and is_unmeasured

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


commit 35d36883e87a714f8b2aa7ca89095f3508530f8d
Author: juga0 <juga at riseup.net>
Date:   Sat Dec 1 10:36:22 2018 +0000

    resultdump: store bandwidth and is_unmeasured
    
    In order to use it in torflow's scaling method.
    Tech-debt is growing repeating Relay in relaylist and resultdump,
    Relay should have Results, not Result has Relay
---
 sbws/lib/resultdump.py | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/sbws/lib/resultdump.py b/sbws/lib/resultdump.py
index 149f6ff..0f7e1af 100644
--- a/sbws/lib/resultdump.py
+++ b/sbws/lib/resultdump.py
@@ -201,7 +201,8 @@ class Result:
         Result class to be happy '''
         def __init__(self, fingerprint, nickname, address, master_key_ed25519,
                      average_bandwidth=None, burst_bandwidth=None,
-                     observed_bandwidth=None):
+                     observed_bandwidth=None, consensus_bandwidth=None,
+                     consensus_bandwidth_is_unmeasured=None):
             self.fingerprint = fingerprint
             self.nickname = nickname
             self.address = address
@@ -209,13 +210,18 @@ class Result:
             self.average_bandwidth = average_bandwidth
             self.burst_bandwidth = burst_bandwidth
             self.observed_bandwidth = observed_bandwidth
+            self.consensus_bandwidth = consensus_bandwidth
+            self.consensus_bandwidth_is_unmeasured = \
+                consensus_bandwidth_is_unmeasured
 
     def __init__(self, relay, circ, dest_url, scanner_nick, t=None):
         self._relay = Result.Relay(relay.fingerprint, relay.nickname,
                                    relay.address, relay.master_key_ed25519,
                                    relay.average_bandwidth,
                                    relay.burst_bandwidth,
-                                   relay.observed_bandwidth)
+                                   relay.observed_bandwidth,
+                                   relay.consensus_bandwidth,
+                                   relay.consensus_bandwidth_is_unmeasured)
         self._circ = circ
         self._dest_url = dest_url
         self._scanner = scanner_nick
@@ -238,6 +244,14 @@ class Result:
         return self._relay.observed_bandwidth
 
     @property
+    def consensus_bandwidth(self):
+        return self._relay.consensus_bandwidth
+
+    @property
+    def consensus_bandwidth_is_unmeasured(self):
+        return self._relay.consensus_bandwidth_is_unmeasured
+
+    @property
     def fingerprint(self):
         return self._relay.fingerprint
 
@@ -487,7 +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['relay_burst_bandwidth'], d['relay_observed_bandwidth'],
+                d['consensus_bandwidth'],
+                d['consensus_bandwidth_is_unmeasured']),
             d['circ'], d['dest_url'], d['scanner'],
             t=d['time'])
 
@@ -499,6 +515,9 @@ class ResultSuccess(Result):
             'relay_average_bandwidth': self.relay_average_bandwidth,
             'relay_burst_bandwidth': self.relay_burst_bandwidth,
             'relay_observed_bandwidth': self.relay_observed_bandwidth,
+            'consensus_bandwidth': self.consensus_bandwidth,
+            'consensus_bandwidth_is_unmeasured':
+                self.consensus_bandwidth_is_unmeasured,
         })
         return d
 





More information about the tor-commits mailing list