[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] new: v3bwfile: Include consensus count header
commit 0bc03df5ee5e8d4ec3ead47d9a9761ea3c8b7978
Author: juga0 <juga@xxxxxxxxxx>
Date: Fri Feb 15 16:54:10 2019 +0000
new: v3bwfile: Include consensus count header
The total number of consensuses seen in the last days.
Part of #28566.
---
sbws/lib/v3bwfile.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index d827029..fa05fbc 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -229,7 +229,9 @@ class V3BWHeader(object):
kwargs = dict()
latest_bandwidth = cls.latest_bandwidth_from_results(results)
earliest_bandwidth = cls.earliest_bandwidth_from_results(results)
+ # NOTE: Blocking, reads file
generator_started = cls.generator_started_from_file(state_fpath)
+ consensus_count = cls.consensus_count_from_file(state_fpath)
timestamp = str(latest_bandwidth)
kwargs['latest_bandwidth'] = unixts_to_isodt_str(latest_bandwidth)
kwargs['earliest_bandwidth'] = unixts_to_isodt_str(earliest_bandwidth)
@@ -240,6 +242,8 @@ class V3BWHeader(object):
kwargs['scanner_country'] = scanner_country
if destinations_countries is not None:
kwargs['destinations_countries'] = destinations_countries
+ if consensus_count is not None:
+ kwargs['recent_consensus_count'] = str(consensus_count)
h = cls(timestamp, **kwargs)
return h
@@ -297,6 +301,14 @@ class V3BWHeader(object):
return None
@staticmethod
+ def consensus_count_from_file(state_fpath):
+ state = State(state_fpath)
+ if 'consensus_count' in state:
+ return state['consensus_count']
+ else:
+ return None
+
+ @staticmethod
def latest_bandwidth_from_results(results):
return round(max([r.time for fp in results for r in results[fp]]))
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits