Commit 1e94279e authored by juga's avatar juga
Browse files

fix: relaylist: Exclude relays without descriptor

Closes #40076
parent 37d5c0ab
Pipeline #4178 passed with stage
in 38 minutes and 40 seconds
......@@ -266,7 +266,7 @@ class Relay:
# 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."""
"""Update this relay server descriptor."""
self._desc = server_descriptor
# XXX: tech-debt: replace `_ns` attr by a a `dequee` of the last
......@@ -275,6 +275,24 @@ class Relay:
"""Update this relay router status (from the consensus)."""
self._ns = router_status
def is_alive(self):
"""Return whether it the server descriptor has certain values.
That indicate that the relay is alive or not.
"""
if self._desc is None:
log.warning(
"Relay %s without server descriptor.", self.fingerprint
)
return False
if self._desc.observed_bandwidth is None:
log.warning(
"Relay %s without observed bandwidth.", self.fingerprint
)
return False
return True
class RelayList:
"""Keeps a list of all relays in the current Tor network and updates it
......@@ -435,8 +453,11 @@ class RelayList:
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)
if r.is_alive():
# Add it to the new list of relays.
new_relays.append(r)
else:
num_old_relays += 1
# And remove it from the new consensus dict, as it has
# already added to the new list.
new_relays_dict.pop(fp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment