summaryrefslogtreecommitdiff
path: root/src/consensus
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-02-28 02:14:27 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-02-28 12:58:47 +0100
commitebb8d4e79c9ea21befad74973da051fa09efb0d0 (patch)
tree24765a56f0cce23b1e337567ba09c03a20ba079d /src/consensus
parentcb130cc9dfc179e3b6cb9f19a7b559106efa3b33 (diff)
consensus: slack-a2a evilness mode and static replication in profiler
Diffstat (limited to 'src/consensus')
-rw-r--r--src/consensus/gnunet-consensus-profiler.c52
-rw-r--r--src/consensus/gnunet-service-consensus.c18
2 files changed, 56 insertions, 14 deletions
diff --git a/src/consensus/gnunet-consensus-profiler.c b/src/consensus/gnunet-consensus-profiler.c
index 290263d95..65542f4cd 100644
--- a/src/consensus/gnunet-consensus-profiler.c
+++ b/src/consensus/gnunet-consensus-profiler.c
@@ -55,6 +55,8 @@ static struct GNUNET_HashCode session_id;
static unsigned int peers_done = 0;
+static int dist_static;
+
static unsigned *results_for_peer;
/**
@@ -217,26 +219,45 @@ do_consensus ()
{
int unique_indices[replication];
unsigned int i;
+ unsigned int j;
+ struct GNUNET_HashCode val;
+ struct GNUNET_SET_Element element;
- for (i = 0; i < num_values; i++)
+ if (dist_static)
{
- unsigned int j;
- struct GNUNET_HashCode val;
- struct GNUNET_SET_Element element;
+ for (i = 0; i < num_values; i++)
+ {
- generate_indices (unique_indices);
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val);
- element.data = &val;
- element.size = sizeof (val);
- for (j = 0; j < replication; j++)
+ element.data = &val;
+ element.size = sizeof (val);
+ for (j = 0; j < replication; j++)
+ {
+ GNUNET_CONSENSUS_insert (consensus_handles[j],
+ &element,
+ NULL, NULL);
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < num_values; i++)
{
- int cid;
+ generate_indices (unique_indices);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val);
- cid = unique_indices[j];
- GNUNET_CONSENSUS_insert (consensus_handles[cid],
- &element,
- NULL, NULL);
+ element.data = &val;
+ element.size = sizeof (val);
+ for (j = 0; j < replication; j++)
+ {
+ int cid;
+
+ cid = unique_indices[j];
+ GNUNET_CONSENSUS_insert (consensus_handles[cid],
+ &element,
+ NULL, NULL);
+ }
}
}
@@ -513,6 +534,9 @@ main (int argc, char **argv)
{ 's', "statistics", NULL,
gettext_noop ("write statistics to file"),
GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename },
+ { 'S', "dist-static", NULL,
+ gettext_noop ("distribute elements to a static subset of good peers"),
+ GNUNET_YES, &GNUNET_GETOPT_set_one, &dist_static },
{ 'V', "verbose", NULL,
gettext_noop ("be more verbose (print received values)"),
GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose },
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index 6662ae8ca..b934f468f 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -1153,6 +1153,7 @@ enum EvilnessType
EVILNESS_CRAM_LEAD,
EVILNESS_CRAM_ECHO,
EVILNESS_SLACK,
+ EVILNESS_SLACK_A2A,
};
enum EvilnessSubType
@@ -1245,6 +1246,10 @@ get_evilness (struct ConsensusSession *session, struct Evilness *evil)
{
evil->type = EVILNESS_SLACK;
}
+ if (0 == strcmp ("slack-a2a", evil_type_str))
+ {
+ evil->type = EVILNESS_SLACK_A2A;
+ }
else if (0 == strcmp ("cram-all", evil_type_str))
{
evil->type = EVILNESS_CRAM_ALL;
@@ -1417,6 +1422,19 @@ commit_set (struct ConsensusSession *session,
"P%u: evil peer: slacking\n",
(unsigned int) session->local_peer_idx);
/* Do nothing. */
+ case EVILNESS_SLACK_A2A:
+ if ( (PHASE_KIND_ALL_TO_ALL_2 == task->key.kind ) ||
+ (PHASE_KIND_ALL_TO_ALL == task->key.kind) )
+ {
+ struct GNUNET_SET_Handle *empty_set;
+ empty_set = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION);
+ GNUNET_SET_commit (setop->op, empty_set);
+ GNUNET_SET_destroy (empty_set);
+ }
+ else
+ {
+ GNUNET_SET_commit (setop->op, set->h);
+ }
break;
case EVILNESS_NONE:
GNUNET_SET_commit (setop->op, set->h);