consensus now implemented with primitive conclusion group selection
[oweals/gnunet.git] / src / consensus / gnunet-consensus.c
index c8a5593f17c26134c9738fe8025785815d7fcc3d..fd6019c20401cb3325fbf11ce32077f9a1c347ad 100644 (file)
@@ -65,6 +65,16 @@ controller_cb(void *cls,
 }
 
 
+static void
+destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *ctx)
+{
+  struct GNUNET_CONSENSUS_Handle *consensus;
+  consensus = cls;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "destroying consensus\n");
+  GNUNET_CONSENSUS_destroy (consensus);
+}
+
+
 /**
  * Called when a conclusion was successful.
  *
@@ -72,14 +82,13 @@ controller_cb(void *cls,
  * @param group
  * @return GNUNET_YES if more consensus groups should be offered, GNUNET_NO if not
  */
-static int
+static void
 conclude_cb (void *cls, const struct GNUNET_CONSENSUS_Group *group)
 {
-  return GNUNET_NO;
+  GNUNET_SCHEDULER_add_now (destroy, cls);
 }
 
 
-
 static void
 generate_indices (int *indices)
 {
@@ -177,6 +186,7 @@ static int
 new_element_cb (void *cls,
                 struct GNUNET_CONSENSUS_Element *element)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "received new element\n");
   return GNUNET_YES;
 }
 
@@ -263,8 +273,11 @@ test_master (void *cls,
   int i;
 
 
+  GNUNET_log_setup ("gnunet-consensus", "INFO", NULL);
+
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n");
 
+
   peers = started_peers;
 
   peer_ids = GNUNET_malloc (num_peers * sizeof (struct GNUNET_PeerIdentity));
@@ -284,6 +297,11 @@ run (void *cls, char *const *args, const char *cfgfile,
 {
   static char *session_str = "gnunet-consensus/test";
 
+  if (num_peers < replication)
+  {
+    fprintf (stderr, "k must be <=n\n");
+    return;
+  }
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "running gnunet-consensus\n");