[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28609 - gnunet/src/consensus
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28609 - gnunet/src/consensus |
Date: |
Wed, 14 Aug 2013 01:39:08 +0200 |
Author: dold
Date: 2013-08-14 01:39:08 +0200 (Wed, 14 Aug 2013)
New Revision: 28609
Modified:
gnunet/src/consensus/gnunet-consensus-profiler.c
gnunet/src/consensus/gnunet-service-consensus.c
Log:
- profiler can be verbose
Modified: gnunet/src/consensus/gnunet-consensus-profiler.c
===================================================================
--- gnunet/src/consensus/gnunet-consensus-profiler.c 2013-08-13 23:00:30 UTC
(rev 28608)
+++ gnunet/src/consensus/gnunet-consensus-profiler.c 2013-08-13 23:39:08 UTC
(rev 28609)
@@ -55,7 +55,9 @@
static unsigned *results_for_peer;
+static int verbose;
+
/**
* Signature of the event handler function called by the
* respective event controller.
@@ -202,10 +204,18 @@
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));
+ }
}
@@ -389,6 +399,9 @@
{ '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;
Modified: gnunet/src/consensus/gnunet-service-consensus.c
===================================================================
--- gnunet/src/consensus/gnunet-service-consensus.c 2013-08-13 23:00:30 UTC
(rev 28608)
+++ gnunet/src/consensus/gnunet-service-consensus.c 2013-08-13 23:39:08 UTC
(rev 28609)
@@ -177,11 +177,15 @@
/**
* Permutation of peers for the current round,
- * maps logical index (for current round) to physical index (location in
info array)
*/
uint32_t *shuffle;
/**
+ * Inverse permutation of peers for the current round,
+ */
+ uint32_t *shuffle_inv;
+
+ /**
* Current round of the exponential scheme.
*/
uint32_t exp_round;
@@ -331,6 +335,11 @@
GNUNET_free (session->shuffle);
session->shuffle = NULL;
}
+ if (NULL != session->shuffle_inv)
+ {
+ GNUNET_free (session->shuffle_inv);
+ session->shuffle_inv = NULL;
+ }
if (NULL != session->info)
{
for (i = 0; i < session->num_peers; i++)
@@ -448,6 +457,8 @@
if (NULL == session->shuffle)
session->shuffle = GNUNET_malloc (session->num_peers * sizeof
(*session->shuffle));
+ if (NULL == session->shuffle_inv)
+ session->shuffle_inv = GNUNET_malloc (session->num_peers * sizeof
(*session->shuffle_inv));
GNUNET_CRYPTO_kdf (randomness, sizeof (randomness),
&session->exp_round, sizeof (uint32_t),
@@ -466,6 +477,10 @@
session->shuffle[x] = session->shuffle[i];
session->shuffle[i] = tmp;
}
+
+ /* create the inverse */
+ for (i = 0; i < session->num_peers; i++)
+ session->shuffle_inv[session->shuffle[i]] = i;
}
@@ -501,7 +516,7 @@
{
/* we are outgoing */
partner_idx = (my_idx + arc) % session->num_peers;
- session->partner_outgoing = &session->info[session->shuffle[partner_idx]];
+ session->partner_outgoing =
&session->info[session->shuffle_inv[partner_idx]];
session->partner_outgoing->exp_subround_finished = GNUNET_NO;
/* are we a 'ghost' of a peer that would exist if
* the number of peers was a power of two, and thus have to partner
@@ -519,7 +534,7 @@
if (0 == (ghost_partner_idx & arc))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ghost partner is %d\n",
ghost_partner_idx);
- session->partner_incoming =
&session->info[session->shuffle[ghost_partner_idx]];
+ session->partner_incoming =
&session->info[session->shuffle_inv[ghost_partner_idx]];
session->partner_incoming->exp_subround_finished = GNUNET_NO;
return;
}
@@ -532,7 +547,7 @@
if (partner_idx < 0)
partner_idx += session->num_peers;
session->partner_outgoing = NULL;
- session->partner_incoming = &session->info[session->shuffle[partner_idx]];
+ session->partner_incoming =
&session->info[session->shuffle_inv[partner_idx]];
session->partner_incoming->exp_subround_finished = GNUNET_NO;
}
@@ -674,15 +689,17 @@
session->exp_subround = 0;
if (NULL == session->shuffle)
session->shuffle = GNUNET_malloc ((sizeof (int)) * session->num_peers);
+ if (NULL == session->shuffle_inv)
+ session->shuffle_inv = GNUNET_malloc ((sizeof (int)) *
session->num_peers);
for (i = 0; i < session->num_peers; i++)
- session->shuffle[i] = i;
+ session->shuffle[i] = session->shuffle_inv[i] = i;
}
else if (session->exp_subround + 1 >= (int) ceil (log2 (session->num_peers)))
{
/* subrounds done, start new log-round */
session->exp_round++;
session->exp_subround = 0;
- //shuffle (session);
+ shuffle (session);
}
else
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28609 - gnunet/src/consensus,
gnunet <=