GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
*/
/**
- * @file consensus/gnunet-consensus.c
+ * @file consensus/gnunet-consensus-profiler.c
* @brief profiling tool for gnunet-consensus
* @author Florian Dold
*/
#include "platform.h"
-#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#include "gnunet_consensus_service.h"
#include "gnunet_testbed_service.h"
static unsigned *results_for_peer;
+static int verbose;
+
/**
* Signature of the event handler function called by the
const struct GNUNET_SET_Element *element)
{
struct GNUNET_CONSENSUS_Handle **chp = cls;
+ int idx = chp - consensus_handles;
GNUNET_assert (NULL != cls);
-
- results_for_peer[chp - consensus_handles]++;
+
+ results_for_peer[idx]++;
+
+ GNUNET_assert (sizeof (struct GNUNET_HashCode) == element->size);
+
+ if (GNUNET_YES == verbose)
+ {
+ printf ("P%d received %s\n", idx, GNUNET_h2s ((struct GNUNET_HashCode *) element->data));
+ }
}
* Signature of a main function for a testcase.
*
* @param cls closure
+ * @param h the run handle
* @param num_peers number of peers in 'peers'
* @param started_peers handle to peers run in the testbed. NULL upon timeout (see
* GNUNET_TESTBED_test_run()).
*/
static void
test_master (void *cls,
+ struct GNUNET_TESTBED_RunHandle *h,
unsigned int num_peers,
struct GNUNET_TESTBED_Peer **started_peers,
unsigned int links_succeeded,
{
static char *session_str = "gnunet-consensus/test";
char *topology;
+ int topology_cmp_result;
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed", "OVERLAY_TOPOLOGY", &topology))
{
return;
}
- if (0 == strcasecmp (topology, "NONE"))
+ topology_cmp_result = strcasecmp (topology, "NONE");
+ GNUNET_free (topology);
+
+ if (0 == topology_cmp_result)
{
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");
{ 't', "timeout", NULL,
gettext_noop ("consensus timeout"),
GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &conclude_timeout },
+ { 'V', "verbose", NULL,
+ gettext_noop ("be more verbose (print received values)"),
+ GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose },
GNUNET_GETOPT_OPTION_END
};
conclude_timeout = GNUNET_TIME_UNIT_SECONDS;