aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-02-24 18:27:21 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-02-24 18:27:21 +0100
commitfa0b5c44f096a68ac0a51c4cbb37c920ceb36bce (patch)
tree09c5b116e7de2e10b228118be97007f2b4b5f052 /src/set
parentebabb581efd0516a80b4d649e0dea852f46329f5 (diff)
downloadgnunet-fa0b5c44f096a68ac0a51c4cbb37c920ceb36bce.tar.gz
gnunet-fa0b5c44f096a68ac0a51c4cbb37c920ceb36bce.zip
add byzantine/force options to profiler
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-set-profiler.c56
1 files changed, 54 insertions, 2 deletions
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c
index 22a9d85cf..971d9746a 100644
--- a/src/set/gnunet-set-profiler.c
+++ b/src/set/gnunet-set-profiler.c
@@ -58,6 +58,10 @@ static struct GNUNET_PeerIdentity local_peer;
58 58
59static struct GNUNET_SET_ListenHandle *set_listener; 59static struct GNUNET_SET_ListenHandle *set_listener;
60 60
61static int byzantine;
62static int force_delta;
63static int force_full;
64
61/** 65/**
62 * Handle to the statistics service. 66 * Handle to the statistics service.
63 */ 67 */
@@ -215,6 +219,10 @@ set_listen_cb (void *cls,
215 const struct GNUNET_MessageHeader *context_msg, 219 const struct GNUNET_MessageHeader *context_msg,
216 struct GNUNET_SET_Request *request) 220 struct GNUNET_SET_Request *request)
217{ 221{
222 /* max. 2 options plus terminator */
223 struct GNUNET_SET_Option opts[3] = {0};
224 unsigned int n_opts = 0;
225
218 if (NULL == request) 226 if (NULL == request)
219 { 227 {
220 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 228 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -224,8 +232,23 @@ set_listen_cb (void *cls,
224 GNUNET_assert (NULL == info2.oh); 232 GNUNET_assert (NULL == info2.oh);
225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
226 "set listen cb called\n"); 234 "set listen cb called\n");
235 if (byzantine)
236 {
237 opts[n_opts++] = (struct GNUNET_SET_Option) { .type = GNUNET_SET_OPTION_BYZANTINE };
238 }
239 GNUNET_assert (!(force_full && force_delta));
240 if (force_full)
241 {
242 opts[n_opts++] = (struct GNUNET_SET_Option) { .type = GNUNET_SET_OPTION_FORCE_FULL };
243 }
244 if (force_delta)
245 {
246 opts[n_opts++] = (struct GNUNET_SET_Option) { .type = GNUNET_SET_OPTION_FORCE_DELTA };
247 }
248
249 opts[n_opts].type = 0;
227 info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC, 250 info2.oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_SYMMETRIC,
228 (struct GNUNET_SET_Option[]) { 0 }, 251 opts,
229 set_result_cb, &info2); 252 set_result_cb, &info2);
230 GNUNET_SET_commit (info2.oh, info2.set); 253 GNUNET_SET_commit (info2.oh, info2.set);
231} 254}
@@ -292,6 +315,9 @@ run (void *cls,
292{ 315{
293 unsigned int i; 316 unsigned int i;
294 struct GNUNET_HashCode hash; 317 struct GNUNET_HashCode hash;
318 /* max. 2 options plus terminator */
319 struct GNUNET_SET_Option opts[3] = {0};
320 unsigned int n_opts = 0;
295 321
296 config = cfg; 322 config = cfg;
297 323
@@ -351,9 +377,26 @@ run (void *cls,
351 set_listener = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION, 377 set_listener = GNUNET_SET_listen (config, GNUNET_SET_OPERATION_UNION,
352 &app_id, set_listen_cb, NULL); 378 &app_id, set_listen_cb, NULL);
353 379
380
381 if (byzantine)
382 {
383 opts[n_opts++] = (struct GNUNET_SET_Option) { .type = GNUNET_SET_OPTION_BYZANTINE };
384 }
385 GNUNET_assert (!(force_full && force_delta));
386 if (force_full)
387 {
388 opts[n_opts++] = (struct GNUNET_SET_Option) { .type = GNUNET_SET_OPTION_FORCE_FULL };
389 }
390 if (force_delta)
391 {
392 opts[n_opts++] = (struct GNUNET_SET_Option) { .type = GNUNET_SET_OPTION_FORCE_DELTA };
393 }
394
395 opts[n_opts].type = 0;
396
354 info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL, 397 info1.oh = GNUNET_SET_prepare (&local_peer, &app_id, NULL,
355 GNUNET_SET_RESULT_SYMMETRIC, 398 GNUNET_SET_RESULT_SYMMETRIC,
356 (struct GNUNET_SET_Option[]) { 0 }, 399 opts,
357 set_result_cb, &info1); 400 set_result_cb, &info1);
358 GNUNET_SET_commit (info1.oh, info1.set); 401 GNUNET_SET_commit (info1.oh, info1.set);
359 GNUNET_SET_destroy (info1.set); 402 GNUNET_SET_destroy (info1.set);
@@ -382,6 +425,15 @@ main (int argc, char **argv)
382 { 'B', "num-second", NULL, 425 { 'B', "num-second", NULL,
383 gettext_noop ("number of values"), 426 gettext_noop ("number of values"),
384 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_b }, 427 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_b },
428 { 'b', "byzantine", NULL,
429 gettext_noop ("use byzantine mode"),
430 GNUNET_NO, &GNUNET_GETOPT_set_one, &byzantine },
431 { 'f', "force-full", NULL,
432 gettext_noop ("force sending full set"),
433 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_full },
434 { 'd', "force-delta", NULL,
435 gettext_noop ("number delta operation"),
436 GNUNET_NO, &GNUNET_GETOPT_set_uint, &force_delta },
385 { 'C', "num-common", NULL, 437 { 'C', "num-common", NULL,
386 gettext_noop ("number of values"), 438 gettext_noop ("number of values"),
387 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_c }, 439 GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_c },