[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [bridgedb/master] Add a new schedule type that never actually rolls over.



Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Mon, 12 Oct 2009 14:34:43 -0400
Subject: Add a new schedule type that never actually rolls over.
Commit: 1472fd9e479cb3415e0352106b6df317849b0b02

This way, the same IP or email will be mapped to the same point in the
hash ring forever.
---
 TODO                 |    4 ++--
 lib/bridgedb/Main.py |    6 ++++--
 lib/bridgedb/Time.py |   22 +++++++++++++++++++++-
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/TODO b/TODO
index 60e379c..0b73856 100644
--- a/TODO
+++ b/TODO
@@ -2,12 +2,12 @@
 RSN:
 . Switch backend to sqlite
 X Drop email->bridge mappings after N days
-- Bump up epoch length a lot.
+o Bump up epoch length a lot.
 . Test DB migration code.
-- Write a spec.
 - Drop email persistence
 - Rate-limit email replies.
 - Stop looking for "get bridges" in emails.
+- Write a spec.
 
 
 Soon:
diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 79f37ad..b13710b 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -253,7 +253,8 @@ def startup(cfg):
             categories,
             answerParameters=ringParams)
         splitter.addRing(ipDistributor, "https", cfg.HTTPS_SHARE)
-        webSchedule = Time.IntervalSchedule("day", 2)
+        #webSchedule = Time.IntervalSchedule("day", 2)
+        webSchedule = Time.NoSchedule()
 
     # As appropriate, create an email-based distributor.
     if cfg.EMAIL_DIST and cfg.EMAIL_SHARE:
@@ -265,7 +266,8 @@ def startup(cfg):
             cfg.EMAIL_DOMAIN_RULES.copy(),
             answerParameters=ringParams)
         splitter.addRing(emailDistributor, "email", cfg.EMAIL_SHARE)
-        emailSchedule = Time.IntervalSchedule("day", 1)
+        #emailSchedule = Time.IntervalSchedule("day", 1)
+        emailSchedule = Time.NoSchedule()
 
     # As appropriate, tell the splitter to leave some bridges unallocated.
     if cfg.RESERVED_SHARE:
diff --git a/lib/bridgedb/Time.py b/lib/bridgedb/Time.py
index 6c263c7..63c50d5 100644
--- a/lib/bridgedb/Time.py
+++ b/lib/bridgedb/Time.py
@@ -11,7 +11,15 @@ import time
 
 KNOWN_INTERVALS = [ "hour", "day", "week", "month" ]
 
-class IntervalSchedule:
+class Schedule:
+    def intervalStart(self, when):
+        raise NotImplemented()
+    def getInterval(self, when):
+        raise NotImplemented()
+    def nextIntervalStarts(self, when):
+        raise NotImplemented()
+
+class IntervalSchedule(Schedule):
     """An IntervalSchedule splits time into somewhat natural periods,
        based on hours, days, weeks, or months.
     """
@@ -97,3 +105,15 @@ class IntervalSchedule:
         elif self.itype == 'hour':
             return self.intervalStart(when) + 3600 * self.count
 
+class NoSchedule(Schedule):
+    """A stub-implementation of Schedule that has only one period for
+       all time."""
+    def __init__(self):
+        pass
+    def intervalStart(self, when):
+        return 0
+    def getInterval(self, when):
+        return "1970"
+    def nextIntervalStarts(self, when):
+        return 2147483647L # INT32_MAX
+
-- 
1.5.6.5