From ab41332191f75fa4f050e072a2b37254267a8f3d Mon Sep 17 00:00:00 2001 From: juga0 <juga@riseup.net> Date: Fri, 22 Mar 2019 16:56:01 +0000 Subject: [PATCH] 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. --- sbws/lib/v3bwfile.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py index e698388e..d126ad66 100644 --- a/sbws/lib/v3bwfile.py +++ b/sbws/lib/v3bwfile.py @@ -977,6 +977,17 @@ class V3BWFile(object): key=lambda l: l.bw) 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 def bw_kb(bw_lines, reverse=False): bw_lines_scaled = copy.deepcopy(bw_lines) -- GitLab