Unverified Commit 11b83c61 authored by Isis Lovecruft's avatar Isis Lovecruft
Browse files

Add COLLECT_TIMESTAMPS option for configuring addOrUpdateBridgeHistory().

 * ADD a new option, `COLLECT_TIMESTAMPS` to the config file to configure
   whether or not to run the timestamp collection code, including
   `Stability.addOrUpdateBridgeHistory()`, in `Main.load()`.
 * FIXES #10724
parent 336eb625
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
# #
# CHANGELOG: # CHANGELOG:
# ~~~~~~~~~~ # ~~~~~~~~~~
# Changes in version 0.0.4 - 2014-01-24
# * ADD COLLECT_TIMESTAMPS option (see #10724). Set it to False for the
# staging instance (etc/test-bridgedb.conf), and True for the production
# server (etc/bridgedb.conf).
#
# Changes in version 0.0.3 - 2014-01-17 # Changes in version 0.0.3 - 2014-01-17
# * UPDATE config from bridgedb.git/bridgedb.conf, without changing any of the # * UPDATE config from bridgedb.git/bridgedb.conf, without changing any of the
# settings. # settings.
...@@ -146,6 +151,19 @@ FORCE_PORTS = [(443, 1)] ...@@ -146,6 +151,19 @@ FORCE_PORTS = [(443, 1)]
# Only "Stable" is now supported. This is a list of (flag,minimum) tuples. # Only "Stable" is now supported. This is a list of (flag,minimum) tuples.
FORCE_FLAGS = [("Stable", 1)] FORCE_FLAGS = [("Stable", 1)]
#---------------------------
# Database/Parsing Options \
#------------------------------------------------------------------------------
#
# These options change various database transaction and descriptor parsing
# behaviours.
#------------------------------------------------------------------------------
# (boolean) If True, then collect, sort, and store all timestamps seen for all
# bridges. This operation is extremely expensive, and should be disabled when
# it is not necessary.
COLLECT_TIMESTAMPS = True
#------------------------------- #-------------------------------
# HTTP(S) Distribution Options \ # HTTP(S) Distribution Options \
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
......
...@@ -140,16 +140,17 @@ def load(state, splitter, clear=False): ...@@ -140,16 +140,17 @@ def load(state, splitter, clear=False):
# ns, then we skip it there, too. # ns, then we skip it there, too.
splitter.insert(bridge) splitter.insert(bridge)
if bridge.getID() in timestamps.keys(): if state.COLLECT_TIMESTAMPS:
ts = timestamps[bridge.getID()][:] if bridge.getID() in timestamps.keys():
ts.sort() ts = timestamps[bridge.getID()][:]
for timestamp in ts: ts.sort()
logging.debug( for timestamp in ts:
"Adding/updating timestamps in BridgeHistory for "\ logging.debug(
"'%s' in database: %s" "Updating BridgeHistory timestamps for %s: %s"
% (bridge.fingerprint, timestamp)) % (bridge.fingerprint, timestamp))
bridgedb.Stability.addOrUpdateBridgeHistory( bridgedb.Stability.addOrUpdateBridgeHistory(
bridge, timestamp) bridge, timestamp)
logging.debug("Closing bridge-server-descriptor file: '%s'" % fname) logging.debug("Closing bridge-server-descriptor file: '%s'" % fname)
f.close() f.close()
......
Supports Markdown
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