[tor-commits] [sbws/master] new: relaylist: Count consensus timestamps

juga at torproject.org juga at torproject.org
Thu Mar 21 18:30:42 UTC 2019


commit 021716b7791bb32caa509681d0cce08258673686
Author: juga0 <juga at riseup.net>
Date:   Fri Feb 15 13:51:19 2019 +0000

    new: relaylist: Count consensus timestamps
    
    that have been seen for a relay and for the relay list.
    
    Part of #28566.
---
 sbws/lib/relaylist.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sbws/lib/relaylist.py b/sbws/lib/relaylist.py
index bee0a14..4cac543 100644
--- a/sbws/lib/relaylist.py
+++ b/sbws/lib/relaylist.py
@@ -205,6 +205,11 @@ class Relay:
         self._add_consensus_timestamp(timestamp)
         self._remove_old_consensus_timestamps()
 
+    @property
+    def consensus_count(self):
+        """Number of times the relay was in a conensus."""
+        return len(self._consensus_timestamps)
+
     def can_exit_to_port(self, port):
         """
         Returns True if the relay has an exit policy and the policy accepts
@@ -363,6 +368,11 @@ class RelayList:
         # Set a new list of relays.
         self._relays = self._init_relays()
 
+    @property
+    def consensus_count(self):
+        """Number of times a new consensus was obtained."""
+        return len(self._consensus_timestamps)
+
     def exits_not_bad_allowing_port(self, port):
         return [r for r in self.exits
                 if r.is_exit_not_bad_allowing_port(port)]





More information about the tor-commits mailing list