[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/maint-1.1] Merge branch 'maint-1.1_bug30733_fetch_early_descriptors' into maint-1.1
commit 05bb23c5718cac8bffa105f88447c6ad4e87731b
Merge: f01a6fe 5986d25
Author: juga0 <juga@xxxxxxxxxx>
Date: Sun Feb 9 19:08:29 2020 +0000
Merge branch 'maint-1.1_bug30733_fetch_early_descriptors' into maint-1.1
sbws/globals.py | 8 ++++++++
sbws/lib/relaylist.py | 26 +++++++++++++++++++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)
diff --cc sbws/lib/relaylist.py
index 19c5073,6fa233c..8069854
--- a/sbws/lib/relaylist.py
+++ b/sbws/lib/relaylist.py
@@@ -289,11 -288,17 +289,22 @@@ class Relay
self.relay_recent_priority_list_count = 0
self.relay_recent_priority_list_count += 1
+ def is_old(self):
+ """Whether the last consensus seen for this relay is older than the
+ 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,21 -438,27 +450,34 @@@
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)
- # Add the relays that were not in the previous consensus
- # If there was an relay in some older previous consensus,
- # it won't get stored, so its previous consensuses are lost,
- # but probably this is fine for now to don't make it more complicated.
+ # 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,
+ # router status and descriptor can't be updated.
+ elif not r.is_old(self._measurements_period):
+ new_relays.append(r)
+ # Otherwise, don't add it to the new list of relays.
+ # For debugging, count the old relays that will be discarded.
+ else:
+ num_old_relays += 1
+
+ # Finally, add the relays that were not in the previous consensus
for fp, ns in new_relays_dict.items():
r = Relay(ns.fingerprint, c, ns=ns, timestamp=timestamp)
new_relays.append(r)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits