-docu, style fixes
[oweals/gnunet.git] / src / consensus / gnunet-consensus-profiler.c
index 6b01f9d8e9ae0503d12d96ca824e935e8f3bba60..ef8e08e081a32d01e800b5ccf5618b933ab04cf9 100644 (file)
@@ -25,6 +25,7 @@
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
+#include "gnunet_time_lib.h"
 #include "gnunet_consensus_service.h"
 #include "gnunet_testbed_service.h"
 
@@ -36,6 +37,8 @@ static unsigned int num_values = 5;
 
 static struct GNUNET_TIME_Relative conclude_timeout;
 
+static struct GNUNET_TIME_Relative consensus_delay;
+
 static struct GNUNET_CONSENSUS_Handle **consensus_handles;
 
 static struct GNUNET_TESTBED_Operation **testbed_operations;
@@ -56,6 +59,16 @@ static unsigned *results_for_peer;
 
 static int verbose;
 
+/**
+ * Start time for all consensuses.
+ */
+static struct GNUNET_TIME_Absolute start;
+
+/**
+ * Deadline for all consensuses.
+ */
+static struct GNUNET_TIME_Absolute deadline;
+
 
 /**
  * Signature of the event handler function called by the
@@ -172,7 +185,6 @@ do_consensus ()
 
   for (i = 0; i < num_peers; i++)
     GNUNET_CONSENSUS_conclude (consensus_handles[i],
-                               conclude_timeout,
                                conclude_cb, &consensus_handles[i]);
 }
 
@@ -259,6 +271,8 @@ connect_adapter (void *cls,
   consensus = GNUNET_CONSENSUS_create (cfg,
                                        num_peers, peer_ids,
                                        &session_id,
+                                       start,
+                                       deadline,
                                        &new_element_cb, chp);
   *chp = (struct GNUNET_CONSENSUS_Handle *) consensus;
   return consensus;
@@ -396,6 +410,9 @@ run (void *cls, char *const *args, const char *cfgfile,
     return;
   }
 
+  start = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), consensus_delay);
+  deadline = GNUNET_TIME_absolute_add (start, conclude_timeout);
+
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "running gnunet-consensus\n");
 
@@ -428,6 +445,9 @@ main (int argc, char **argv)
       { 't', "timeout", NULL,
         gettext_noop ("consensus timeout"),
         GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &conclude_timeout },
+      { 'd', "delay", NULL,
+        gettext_noop ("delay until consensus starts"),
+        GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &consensus_delay },
       { 'V', "verbose", NULL,
         gettext_noop ("be more verbose (print received values)"),
         GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose },