consensus now implemented with primitive conclusion group selection
[oweals/gnunet.git] / src / consensus / gnunet-consensus.c
index 222ec3e9df7c6b224af2a85de23ef7cb4d29549b..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)
 {
@@ -288,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");