]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Introduce useful SRV funcs (start time of prev protocol run)
authorGeorge Kadianakis <desnacked@riseup.net>
Thu, 14 Jun 2018 12:25:43 +0000 (15:25 +0300)
committerNick Mathewson <nickm@torproject.org>
Tue, 17 Jul 2018 19:57:46 +0000 (15:57 -0400)
src/or/shared_random_client.c
src/or/shared_random_client.h

index f0b13a171e7beb6e8b059db022f99634c1cc14b6..d787b6b2ec53f01decaee13eee5d85cfeeea65a3 100644 (file)
@@ -243,6 +243,19 @@ sr_state_get_start_time_of_current_protocol_run(time_t now)
   return beginning_of_current_round - time_elapsed_since_start_of_run;
 }
 
+/** Return the start time of the previous SR protocol run. See
+ *  sr_state_get_start_time_of_current_protocol_run() for more details.  */
+time_t
+sr_state_get_start_time_of_previous_protocol_run(time_t now)
+{
+  time_t start_time_of_current_run =
+    sr_state_get_start_time_of_current_protocol_run(now);
+
+  /* We get the start time of previous protocol run, by getting the start time
+   * of current run and the subtracting a full protocol run from that. */
+  return start_time_of_current_run - sr_state_get_protocol_run_duration();
+}
+
 /** Return the time (in seconds) it takes to complete a full SR protocol phase
  *  (e.g. the commit phase). */
 unsigned int
index 079829496c433d9ccf902cc9c77aca6ca58650a2..35ebb1bd57aebff3ae71521c3c2f08e35b59f9f1 100644 (file)
@@ -35,6 +35,7 @@ sr_srv_t *sr_parse_srv(const smartlist_t *args);
 #define SHARED_RANDOM_N_PHASES 2
 
 time_t sr_state_get_start_time_of_current_protocol_run(time_t now);
+time_t sr_state_get_start_time_of_previous_protocol_run(time_t now);
 unsigned int sr_state_get_phase_duration(void);
 unsigned int sr_state_get_protocol_run_duration(void);
 time_t get_start_time_of_current_round(void);