Commit 021716b7 authored by juga's avatar juga
Browse files

new: relaylist: Count consensus timestamps

that have been seen for a relay and for the relay list.

Part of #28566.
parent 417ebfa9
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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)]