[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/master] new: relaylist: Store total consensus count



commit 1387f91ce469f2c54dfdd067cfd2cd0b3b9099a1
Author: juga0 <juga@xxxxxxxxxx>
Date:   Fri Feb 15 16:06:53 2019 +0000

    new: relaylist: Store total consensus count
    
    to the state file.
    To know the total number of consensus seen in the last days.
    
    Part of #28566.
---
 sbws/core/scanner.py  |  2 +-
 sbws/lib/relaylist.py | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/sbws/core/scanner.py b/sbws/core/scanner.py
index 503f9cc..73d0b0e 100644
--- a/sbws/core/scanner.py
+++ b/sbws/core/scanner.py
@@ -627,7 +627,7 @@ def run_speedtest(args, conf):
     # To do not have to pass args and conf to RelayList, pass an extra
     # argument with the data_period
     measurements_period = conf.getint('general', 'data_period')
-    rl = RelayList(args, conf, controller, measurements_period)
+    rl = RelayList(args, conf, controller, measurements_period, state)
     cb = CB(args, conf, controller, rl)
     rd = ResultDump(args, conf)
     rp = RelayPrioritizer(args, conf, rl, rd)
diff --git a/sbws/lib/relaylist.py b/sbws/lib/relaylist.py
index 4cac543..3857718 100644
--- a/sbws/lib/relaylist.py
+++ b/sbws/lib/relaylist.py
@@ -234,7 +234,7 @@ class RelayList:
     '''
 
     def __init__(self, args, conf, controller,
-                 measurements_period=MEASUREMENTS_PERIOD):
+                 measurements_period=MEASUREMENTS_PERIOD, state=None):
         self._controller = controller
         self.rng = random.SystemRandom()
         self._refresh_lock = Lock()
@@ -246,6 +246,7 @@ class RelayList:
         self._relays = []
         # The period of time for which the measurements are keep.
         self._measurements_period = measurements_period
+        self._state = state
         self._refresh()
 
     def _need_refresh(self):
@@ -368,6 +369,13 @@ class RelayList:
         # Set a new list of relays.
         self._relays = self._init_relays()
 
+        log.info("Number of consensuses obtained in the last %s days: %s.",
+                 int(self._measurements_period / 24 / 60 / 60),
+                 self.consensus_count)
+        # NOTE: blocking, writes to file!
+        if self._state is not None:
+            self._state['consensus_count'] = self.consensus_count
+
     @property
     def consensus_count(self):
         """Number of times a new consensus was obtained."""



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits