diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-02-28 02:14:27 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-02-28 12:58:47 +0100 |
commit | ebb8d4e79c9ea21befad74973da051fa09efb0d0 (patch) | |
tree | 24765a56f0cce23b1e337567ba09c03a20ba079d | |
parent | cb130cc9dfc179e3b6cb9f19a7b559106efa3b33 (diff) | |
download | gnunet-ebb8d4e79c9ea21befad74973da051fa09efb0d0.tar.gz gnunet-ebb8d4e79c9ea21befad74973da051fa09efb0d0.zip |
consensus: slack-a2a evilness mode and static replication in profiler
-rw-r--r-- | src/consensus/gnunet-consensus-profiler.c | 52 | ||||
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 18 |
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; | |||
55 | 55 | ||
56 | static unsigned int peers_done = 0; | 56 | static unsigned int peers_done = 0; |
57 | 57 | ||
58 | static int dist_static; | ||
59 | |||
58 | static unsigned *results_for_peer; | 60 | static unsigned *results_for_peer; |
59 | 61 | ||
60 | /** | 62 | /** |
@@ -217,26 +219,45 @@ do_consensus () | |||
217 | { | 219 | { |
218 | int unique_indices[replication]; | 220 | int unique_indices[replication]; |
219 | unsigned int i; | 221 | unsigned int i; |
222 | unsigned int j; | ||
223 | struct GNUNET_HashCode val; | ||
224 | struct GNUNET_SET_Element element; | ||
220 | 225 | ||
221 | for (i = 0; i < num_values; i++) | 226 | if (dist_static) |
222 | { | 227 | { |
223 | unsigned int j; | 228 | for (i = 0; i < num_values; i++) |
224 | struct GNUNET_HashCode val; | 229 | { |
225 | struct GNUNET_SET_Element element; | ||
226 | 230 | ||
227 | generate_indices (unique_indices); | 231 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val); |
228 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val); | ||
229 | 232 | ||
230 | element.data = &val; | 233 | element.data = &val; |
231 | element.size = sizeof (val); | 234 | element.size = sizeof (val); |
232 | for (j = 0; j < replication; j++) | 235 | for (j = 0; j < replication; j++) |
236 | { | ||
237 | GNUNET_CONSENSUS_insert (consensus_handles[j], | ||
238 | &element, | ||
239 | NULL, NULL); | ||
240 | } | ||
241 | } | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | for (i = 0; i < num_values; i++) | ||
233 | { | 246 | { |
234 | int cid; | 247 | generate_indices (unique_indices); |
248 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &val); | ||
235 | 249 | ||
236 | cid = unique_indices[j]; | 250 | element.data = &val; |
237 | GNUNET_CONSENSUS_insert (consensus_handles[cid], | 251 | element.size = sizeof (val); |
238 | &element, | 252 | for (j = 0; j < replication; j++) |
239 | NULL, NULL); | 253 | { |
254 | int cid; | ||
255 | |||
256 | cid = unique_indices[j]; | ||
257 | GNUNET_CONSENSUS_insert (consensus_handles[cid], | ||
258 | &element, | ||
259 | NULL, NULL); | ||
260 | } | ||
240 | } | 261 | } |
241 | } | 262 | } |
242 | 263 | ||
@@ -513,6 +534,9 @@ main (int argc, char **argv) | |||
513 | { 's', "statistics", NULL, | 534 | { 's', "statistics", NULL, |
514 | gettext_noop ("write statistics to file"), | 535 | gettext_noop ("write statistics to file"), |
515 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename }, | 536 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &statistics_filename }, |
537 | { 'S', "dist-static", NULL, | ||
538 | gettext_noop ("distribute elements to a static subset of good peers"), | ||
539 | GNUNET_YES, &GNUNET_GETOPT_set_one, &dist_static }, | ||
516 | { 'V', "verbose", NULL, | 540 | { 'V', "verbose", NULL, |
517 | gettext_noop ("be more verbose (print received values)"), | 541 | gettext_noop ("be more verbose (print received values)"), |
518 | GNUNET_NO, &GNUNET_GETOPT_set_one, &verbose }, | 542 | 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 | |||
1153 | EVILNESS_CRAM_LEAD, | 1153 | EVILNESS_CRAM_LEAD, |
1154 | EVILNESS_CRAM_ECHO, | 1154 | EVILNESS_CRAM_ECHO, |
1155 | EVILNESS_SLACK, | 1155 | EVILNESS_SLACK, |
1156 | EVILNESS_SLACK_A2A, | ||
1156 | }; | 1157 | }; |
1157 | 1158 | ||
1158 | enum EvilnessSubType | 1159 | enum EvilnessSubType |
@@ -1245,6 +1246,10 @@ get_evilness (struct ConsensusSession *session, struct Evilness *evil) | |||
1245 | { | 1246 | { |
1246 | evil->type = EVILNESS_SLACK; | 1247 | evil->type = EVILNESS_SLACK; |
1247 | } | 1248 | } |
1249 | if (0 == strcmp ("slack-a2a", evil_type_str)) | ||
1250 | { | ||
1251 | evil->type = EVILNESS_SLACK_A2A; | ||
1252 | } | ||
1248 | else if (0 == strcmp ("cram-all", evil_type_str)) | 1253 | else if (0 == strcmp ("cram-all", evil_type_str)) |
1249 | { | 1254 | { |
1250 | evil->type = EVILNESS_CRAM_ALL; | 1255 | evil->type = EVILNESS_CRAM_ALL; |
@@ -1417,6 +1422,19 @@ commit_set (struct ConsensusSession *session, | |||
1417 | "P%u: evil peer: slacking\n", | 1422 | "P%u: evil peer: slacking\n", |
1418 | (unsigned int) session->local_peer_idx); | 1423 | (unsigned int) session->local_peer_idx); |
1419 | /* Do nothing. */ | 1424 | /* Do nothing. */ |
1425 | case EVILNESS_SLACK_A2A: | ||
1426 | if ( (PHASE_KIND_ALL_TO_ALL_2 == task->key.kind ) || | ||
1427 | (PHASE_KIND_ALL_TO_ALL == task->key.kind) ) | ||
1428 | { | ||
1429 | struct GNUNET_SET_Handle *empty_set; | ||
1430 | empty_set = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION); | ||
1431 | GNUNET_SET_commit (setop->op, empty_set); | ||
1432 | GNUNET_SET_destroy (empty_set); | ||
1433 | } | ||
1434 | else | ||
1435 | { | ||
1436 | GNUNET_SET_commit (setop->op, set->h); | ||
1437 | } | ||
1420 | break; | 1438 | break; |
1421 | case EVILNESS_NONE: | 1439 | case EVILNESS_NONE: |
1422 | GNUNET_SET_commit (setop->op, set->h); | 1440 | GNUNET_SET_commit (setop->op, set->h); |