[Nym3-commit] r511 - trunk/nymbaron/Server

jr at conuropsis.org jr at conuropsis.org
Tue Apr 4 22:51:26 CEST 2006


Author: jr
Date: 2006-04-04 22:51:25 +0200 (Tue, 04 Apr 2006)
New Revision: 511

Modified:
   trunk/nymbaron/Server/User.py
Log:
- add a surbUsage cleanup function


Modified: trunk/nymbaron/Server/User.py
===================================================================
--- trunk/nymbaron/Server/User.py	2006-04-03 21:59:08 UTC (rev 510)
+++ trunk/nymbaron/Server/User.py	2006-04-04 20:51:25 UTC (rev 511)
@@ -402,6 +402,7 @@
         using the surbs provided by the nymholder. Adds a status control
         message if the add_status argument is True. Also updates the number
         of surbs"""
+        #TODO add surb usage management
         #TODO add the filling of the remaining place available in the the
         #message by syns and msgs here
         statusc = Message.Status()
@@ -795,3 +796,15 @@
             self.encryptSyn(firstclear, firstclear+nclear)
             ret.append(bfprepare(self.syn[firstclear]))
         return ret
+    
+    def cleanSurbUsage(self):
+        """Remove from the list in self.surbUsage elements older than 24h and
+        update the surbUsage"""
+        yesterday = time.time() - 24 * 3600
+        usage = self.data['surbUsage'][0]
+        for i, (t, n) in self.data['surbUsage'][1]:
+            if t < yesterday:
+                usage = usage + n
+            else:
+                break
+        self.data['surbUsage'] = usage, self.data['surbUsage'][1][i:]



More information about the Nym3-commit mailing list