Commit ab413321 authored by juga  's avatar juga
Browse files

fix: v3bwfile: Add method to set under_min_report KeyValue

in the Bandwidth Lines.
When the minimum percent of relays it's not reached, still report
the relays but set KeyValues accordingly so that Tor doesn't vote
on their bandwidth.

Part of #29853.
parent 702ceedc
...@@ -977,6 +977,17 @@ class V3BWFile(object): ...@@ -977,6 +977,17 @@ class V3BWFile(object):
key=lambda l: l.bw) key=lambda l: l.bw)
return cls(header, bw_lines) return cls(header, bw_lines)
@staticmethod
def set_under_min_report(bw_lines):
"""
Mondify the Bandwidth Lines adding the KeyValue `under_min_report`,
`vote`.
"""
log.debug("Setting `under_min_report` to %s lines.", len(bw_lines))
for l in bw_lines:
l.under_min_report = 1
l.vote = 0
@staticmethod @staticmethod
def bw_kb(bw_lines, reverse=False): def bw_kb(bw_lines, reverse=False):
bw_lines_scaled = copy.deepcopy(bw_lines) bw_lines_scaled = copy.deepcopy(bw_lines)
......
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