[tor-commits] [bridgedb/master] Add COLLECT_TIMESTAMPS option for configuring addOrUpdateBridgeHistory().

isis at torproject.org isis at torproject.org
Tue Feb 4 00:28:47 UTC 2014


commit 11b83c612090d673d4f23ccaf85be66ec5588e8a
Author: Isis Lovecruft <isis at torproject.org>
Date:   Fri Jan 24 20:49:39 2014 +0000

    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
---
 bridgedb.conf        |   18 ++++++++++++++++++
 lib/bridgedb/Main.py |   21 +++++++++++----------
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/bridgedb.conf b/bridgedb.conf
index bf97077..bcde0cf 100644
--- a/bridgedb.conf
+++ b/bridgedb.conf
@@ -20,6 +20,11 @@
 #
 # 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
 #   * UPDATE config from bridgedb.git/bridgedb.conf, without changing any of the
 #     settings.
@@ -146,6 +151,19 @@ FORCE_PORTS = [(443, 1)]
 # Only "Stable" is now supported.  This is a list of (flag,minimum) tuples.
 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  \
 #------------------------------------------------------------------------------
diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 24ec825..a46f22f 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -140,16 +140,17 @@ def load(state, splitter, clear=False):
                 # ns, then we skip it there, too.
                 splitter.insert(bridge)
 
-                if bridge.getID() in timestamps.keys():
-                    ts = timestamps[bridge.getID()][:]
-                    ts.sort()
-                    for timestamp in ts:
-                        logging.debug(
-                            "Adding/updating timestamps in BridgeHistory for "\
-                            "'%s' in database: %s"
-                            % (bridge.fingerprint, timestamp))
-                        bridgedb.Stability.addOrUpdateBridgeHistory(
-                            bridge, timestamp)
+                if state.COLLECT_TIMESTAMPS:
+                    if bridge.getID() in timestamps.keys():
+                        ts = timestamps[bridge.getID()][:]
+                        ts.sort()
+                        for timestamp in ts:
+                            logging.debug(
+                                "Updating BridgeHistory timestamps for %s: %s"
+                                % (bridge.fingerprint, timestamp))
+                            bridgedb.Stability.addOrUpdateBridgeHistory(
+                                bridge, timestamp)
+
         logging.debug("Closing bridge-server-descriptor file: '%s'" % fname)
         f.close()
 





More information about the tor-commits mailing list