Commit 05bb23c5 authored by juga's avatar juga
Browse files

Merge branch 'maint-1.1_bug30733_fetch_early_descriptors' into maint-1.1

parents f01a6fe9 5986d257
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -36,6 +36,14 @@ TORRC_STARTING_POINT = {
    'SafeLogging': '0',
    'LogTimeGranularity': '1',
    'ProtocolWarnings': '1',
    # To be able to responde to MaxAdvertisedBandwidth as soon as possible.
    # If ``FetchDirInfoExtraEarly` is set, but not
    # `FetchDirInfoEarly`, Tor will throw this error:
    # `FetchDirInfoExtraEarly requires that you also set FetchDirInfoEarly`
    'FetchDirInfoEarly': '1',
    'FetchDirInfoExtraEarly': '1',
    # To make Tor keep fetching descriptors, even when idle.
    'FetchUselessDescriptors': '1'
}
# Options that need to be set at runtime.
TORRC_RUNTIME_OPTIONS = {
+25 −1
Original line number Diff line number Diff line
@@ -294,6 +294,17 @@ class Relay:
        measurement period.
        """
        return timestamp.is_old(self.last_consensus_timestamp)
    # XXX: tech-debt: replace `_desc` attr by a a `dequee` of the last
    # descriptors seen for this relay and the timestamp.
    def update_server_descriptor(self, server_descriptor):
        """Update this relay server descriptor (from the consensus."""
        self._desc = server_descriptor

    # XXX: tech-debt: replace `_ns` attr by a a `dequee` of the last
    # router statuses seen for this relay and the timestampt.
    def update_router_status(self, router_status):
        """Update this relay router status (from the consensus)."""
        self._ns = router_status


class RelayList:
@@ -439,9 +450,22 @@ class RelayList:
        relays = copy.deepcopy(self._relays)
        for r in relays:
            if r.fingerprint in new_relays_dict.keys():
                # If a relay in the previous consensus and is in the current
                # one, update its timestamp, router status and descriptor.
                fp = r.fingerprint
                r.update_consensus_timestamps(timestamp)
                new_relays_dict.pop(r.fingerprint)
                # new_relays_dict[fp] is the router status.
                r.update_router_status(new_relays_dict[fp])
                try:
                    descriptor = c.get_server_descriptor(fp, default=None)
                except (DescriptorUnavailable, ControllerError) as e:
                    log.exception("Exception trying to get desc %s", e)
                r.update_server_descriptor(descriptor)
                # Add it to the new list of relays.
                new_relays.append(r)
                # And remove it from the new consensus dict, as it has
                # already added to the new list.
                new_relays_dict.pop(fp)

            # If the relay is not in the current consensus but is not "old"
            # yet, add it to the new list of relays too, though its timestamp,