gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28551 - gnunet/src/consensus


From: gnunet
Subject: [GNUnet-SVN] r28551 - gnunet/src/consensus
Date: Tue, 13 Aug 2013 00:59:35 +0200

Author: dold
Date: 2013-08-13 00:59:35 +0200 (Tue, 13 Aug 2013)
New Revision: 28551

Modified:
   gnunet/src/consensus/gnunet-consensus.c
Log:
- show received elements in consensus profiler


Modified: gnunet/src/consensus/gnunet-consensus.c
===================================================================
--- gnunet/src/consensus/gnunet-consensus.c     2013-08-12 21:56:49 UTC (rev 
28550)
+++ gnunet/src/consensus/gnunet-consensus.c     2013-08-12 22:59:35 UTC (rev 
28551)
@@ -53,7 +53,9 @@
 
 static unsigned int peers_done = 0;
 
+static unsigned *results_for_peer;
 
+
 /**
  * Signature of the event handler function called by the
  * respective event controller.
@@ -78,9 +80,11 @@
   peers_done++;
   if (peers_done == num_peers)
   {
-    int i;
+    unsigned int i;
     for (i = 0; i < num_peers; i++)
       GNUNET_TESTBED_operation_done (testbed_operations[i]);
+    for (i = 0; i < num_peers; i++)
+      printf ("P%u got %u of %u elements\n", i, results_for_peer[i], 
num_values);
     GNUNET_SCHEDULER_shutdown ();
   }
 }
@@ -174,7 +178,6 @@
                   void *ca_result,
                   const char *emsg)
 {
-  struct GNUNET_CONSENSUS_Handle **chp;
 
   if (NULL != emsg)
   {
@@ -182,12 +185,10 @@
     GNUNET_assert (0);
   }
 
+  num_connected_handles++;
+
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "connect complete\n");
 
-  chp = (struct GNUNET_CONSENSUS_Handle **) cls;
-  *chp = (struct GNUNET_CONSENSUS_Handle *) ca_result;
-  num_connected_handles++;
-
   if (num_connected_handles == num_peers)
   {
     do_consensus ();
@@ -199,7 +200,11 @@
 new_element_cb (void *cls,
                 const struct GNUNET_SET_Element *element)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "received new element\n");
+  struct GNUNET_CONSENSUS_Handle **chp = cls;
+
+  GNUNET_assert (NULL != cls);
+  
+  results_for_peer[chp - consensus_handles]++;
 }
 
 
@@ -217,10 +222,13 @@
 connect_adapter (void *cls,
                  const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  struct GNUNET_CONSENSUS_Handle **chp = cls;
   struct GNUNET_CONSENSUS_Handle *consensus;
+  chp = (struct GNUNET_CONSENSUS_Handle **) cls;
+
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "connect adapter, %d peers\n", 
num_peers);
-  consensus = GNUNET_CONSENSUS_create (cfg, num_peers, peer_ids, &session_id, 
new_element_cb, NULL);
-  GNUNET_assert (NULL != consensus);
+  consensus = GNUNET_CONSENSUS_create (cfg, num_peers, peer_ids, &session_id, 
new_element_cb, chp);
+  *chp = (struct GNUNET_CONSENSUS_Handle *) consensus;
   return consensus;
 }
 
@@ -268,8 +276,8 @@
     if (num_retrieved_peer_ids == num_peers)
       for (i = 0; i < num_peers; i++)
         testbed_operations[i] =
-            GNUNET_TESTBED_service_connect (NULL, peers[i], "consensus", 
connect_complete, &consensus_handles[i],
-                                            connect_adapter, 
disconnect_adapter, NULL);
+            GNUNET_TESTBED_service_connect (NULL, peers[i], "consensus", 
connect_complete, NULL,
+                                            connect_adapter, 
disconnect_adapter, &consensus_handles[i]);
   }
   else
   {
@@ -309,6 +317,7 @@
 
   peer_ids = GNUNET_malloc (num_peers * sizeof (struct GNUNET_PeerIdentity));
 
+  results_for_peer = GNUNET_malloc (num_peers * sizeof (unsigned int));
   consensus_handles = GNUNET_malloc (num_peers * sizeof (struct 
ConsensusHandle *));
   testbed_operations = GNUNET_malloc (num_peers * sizeof (struct 
ConsensusHandle *));
 
@@ -324,7 +333,24 @@
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   static char *session_str = "gnunet-consensus/test";
+  char *topology;
 
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed", 
"OVERLAY_TOPOLOGY", &topology))
+  {
+    fprintf (stderr, "'OVERLAY_TOPOLOGY' not found in 'testbed' config 
section, "
+                     "seems like you passed the wrong configuration file\n");
+    return;
+  }
+
+  if (0 == strcasecmp (topology, "NONE"))
+  {
+    fprintf (stderr, "'OVERLAY_TOPOLOGY' set to 'NONE', "
+                     "seems like you passed the wrong configuration file\n");
+    return;
+  }
+
+  GNUNET_free (topology);
+
   if (num_peers < replication)
   {
     fprintf (stderr, "k must be <=n\n");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]