GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 27e2112a authored by juga  's avatar juga
Browse files

fix: v3bwfile: !refactor, replace constants

- Add new KeyValues constants
- Remove HEADER_KEYS_V1X constant, only used once
- Replace HEADER_UNORDERED_KEYS with the new constants

Part of #30196.
parent 017c7c10
......@@ -34,16 +34,32 @@ KEYVALUE_SEP_V2 = ' '
# =================
# KeyValues that need to be in a specific order in the Bandwidth File.
HEADER_KEYS_V1_1_ORDERED = ['version']
# List of the extra KeyValues accepted by the class
HEADER_KEYS_V1X = [
# KeyValues that are not initialized from the state file nor the measurements.
# They can also be pass as an argument to `Header` to overwrite default values,
# what is done in unit tests.
# `latest bandwidth` is special cause it gets its value from timestamp, which
# is not a KeyValue, but it's always pass as an agument.
# It could be separaed in other list, but so far there is no need, cause:
# 1. when it's pass to the Header to initialize it, it's just ignored.
# 2. when the file is created, it's took into account.
HEADER_KEYS_V1_1_SELF_INITIALIZED = [
"software",
"software_version",
"file_created",
"latest_bandwidth",
]
# KeyValues that are initialized from arguments.
HEADER_KEYS_V1_1_TO_INIT = [
"earliest_bandwidth",
"generator_started",
]
# KeyValues added in the Bandwidth File v1.3.0
HEADER_KEYS_V1_3 = [
"scanner_country",
"destinations_countries",
]
# number_eligible_relays is the number that ends in the bandwidth file
# ie, have not been excluded by one of the filters in 4. below
# They should be call recent_measurement_included_count to be congruent
......@@ -112,9 +128,13 @@ HEADER_INIT_KEYS = \
HEADER_INT_KEYS = HEADER_KEYS_V1_2 + HEADER_KEYS_V1_4
# List of all unordered KeyValues currently being used to generate the file
HEADER_UNORDERED_KEYS = HEADER_KEYS_V1X + HEADER_KEYS_V1_2 + \
['latest_bandwidth'] + \
HEADER_KEYS_V1_4
HEADER_UNORDERED_KEYS = (
HEADER_KEYS_V1_1_SELF_INITIALIZED
+ HEADER_KEYS_V1_1_TO_INIT
+ HEADER_KEYS_V1_3
+ HEADER_KEYS_V1_2
+ HEADER_KEYS_V1_4
)
# List of all the KeyValues currently being used to generate the file
HEADER_ALL_KEYS = HEADER_KEYS_V1_1_ORDERED + HEADER_UNORDERED_KEYS
......
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