aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_multipeer.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/dht/test_dht_multipeer.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/dht/test_dht_multipeer.c')
-rw-r--r--src/dht/test_dht_multipeer.c96
1 files changed, 40 insertions, 56 deletions
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c
index 3bbf44be1..779aff88d 100644
--- a/src/dht/test_dht_multipeer.c
+++ b/src/dht/test_dht_multipeer.c
@@ -394,8 +394,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
394 * @param data pointer to the result data 394 * @param data pointer to the result data
395 */ 395 */
396void 396void
397get_result_iterator (void *cls, 397get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
398 struct GNUNET_TIME_Absolute exp,
399 const GNUNET_HashCode * key, 398 const GNUNET_HashCode * key,
400 const struct GNUNET_PeerIdentity *const *get_path, 399 const struct GNUNET_PeerIdentity *const *get_path,
401 const struct GNUNET_PeerIdentity *const *put_path, 400 const struct GNUNET_PeerIdentity *const *put_path,
@@ -473,15 +472,11 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
473 /* Insert the data at the first peer */ 472 /* Insert the data at the first peer */
474 GNUNET_assert (test_get->dht_handle != NULL); 473 GNUNET_assert (test_get->dht_handle != NULL);
475 outstanding_gets++; 474 outstanding_gets++;
476 test_get->get_handle = GNUNET_DHT_get_start (test_get->dht_handle, 475 test_get->get_handle =
477 GNUNET_TIME_UNIT_FOREVER_REL, 476 GNUNET_DHT_get_start (test_get->dht_handle, GNUNET_TIME_UNIT_FOREVER_REL,
478 GNUNET_BLOCK_TYPE_TEST, 477 GNUNET_BLOCK_TYPE_TEST, &key,
479 &key, 478 DEFAULT_GET_REPLICATION, route_option, NULL, 0,
480 DEFAULT_GET_REPLICATION, 479 NULL, 0, &get_result_iterator, test_get);
481 route_option,
482 NULL, 0,
483 NULL, 0,
484 &get_result_iterator, test_get);
485#if VERBOSE 480#if VERBOSE
486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n", 481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n",
487 test_get->uid, test_get->daemon->shortname); 482 test_get->uid, test_get->daemon->shortname);
@@ -546,14 +541,10 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
546 541
547 GNUNET_assert (test_put->dht_handle != NULL); 542 GNUNET_assert (test_put->dht_handle != NULL);
548 outstanding_puts++; 543 outstanding_puts++;
549 GNUNET_DHT_put (test_put->dht_handle, 544 GNUNET_DHT_put (test_put->dht_handle, &key, DEFAULT_PUT_REPLICATION,
550 &key, 545 route_option, GNUNET_BLOCK_TYPE_TEST, sizeof (data), data,
551 DEFAULT_PUT_REPLICATION, 546 GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL,
552 route_option, 547 &put_finished, test_put);
553 GNUNET_BLOCK_TYPE_TEST,
554 sizeof (data), data,
555 GNUNET_TIME_UNIT_FOREVER_ABS,
556 GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, test_put);
557 test_put->disconnect_task = 548 test_put->disconnect_task =
558 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), 549 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (),
559 &put_disconnect_task, test_put); 550 &put_disconnect_task, test_put);
@@ -616,10 +607,8 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
616 * failure (peers failed to connect). 607 * failure (peers failed to connect).
617 */ 608 */
618void 609void
619topology_callback (void *cls, 610topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
620 const struct GNUNET_PeerIdentity *first, 611 const struct GNUNET_PeerIdentity *second, uint32_t distance,
621 const struct GNUNET_PeerIdentity *second,
622 uint32_t distance,
623 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 612 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
624 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 613 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
625 struct GNUNET_TESTING_Daemon *first_daemon, 614 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -653,9 +642,9 @@ topology_callback (void *cls,
653 total_connections); 642 total_connections);
654#endif 643#endif
655 GNUNET_SCHEDULER_cancel (die_task); 644 GNUNET_SCHEDULER_cancel (die_task);
656 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 645 die_task =
657 &end_badly, 646 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
658 "from setup puts/gets"); 647 "from setup puts/gets");
659 648
660 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 649 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
661 (GNUNET_TIME_UNIT_SECONDS, 2), 650 (GNUNET_TIME_UNIT_SECONDS, 2),
@@ -671,8 +660,7 @@ topology_callback (void *cls,
671} 660}
672 661
673static void 662static void
674peers_started_callback (void *cls, 663peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
675 const struct GNUNET_PeerIdentity *id,
676 const struct GNUNET_CONFIGURATION_Handle *cfg, 664 const struct GNUNET_CONFIGURATION_Handle *cfg,
677 struct GNUNET_TESTING_Daemon *d, const char *emsg) 665 struct GNUNET_TESTING_Daemon *d, const char *emsg)
678{ 666{
@@ -702,16 +690,14 @@ peers_started_callback (void *cls,
702 expected_connections = -1; 690 expected_connections = -1;
703 if ((pg != NULL) && (peers_left == 0)) 691 if ((pg != NULL) && (peers_left == 0))
704 { 692 {
705 expected_connections = GNUNET_TESTING_connect_topology (pg, 693 expected_connections =
706 connection_topology, 694 GNUNET_TESTING_connect_topology (pg, connection_topology,
707 connect_topology_option, 695 connect_topology_option,
708 connect_topology_option_modifier, 696 connect_topology_option_modifier,
709 TIMEOUT, 697 TIMEOUT, num_peers, NULL, NULL);
710 num_peers,
711 NULL, NULL);
712#if VERBOSE 698#if VERBOSE
713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n",
714 "Have %d expected connections\n", expected_connections); 700 expected_connections);
715#endif 701#endif
716 } 702 }
717 703
@@ -722,9 +708,9 @@ peers_started_callback (void *cls,
722 "from connect topology (bad return)"); 708 "from connect topology (bad return)");
723 } 709 }
724 710
725 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 711 die_task =
726 &end_badly, 712 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
727 "from connect topology (timeout)"); 713 "from connect topology (timeout)");
728 714
729 ok = 0; 715 ok = 0;
730 } 716 }
@@ -751,9 +737,9 @@ create_topology ()
751 "from create topology (bad return)"); 737 "from create topology (bad return)");
752 } 738 }
753 GNUNET_SCHEDULER_cancel (die_task); 739 GNUNET_SCHEDULER_cancel (die_task);
754 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 740 die_task =
755 &end_badly, 741 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
756 "from continue startup (timeout)"); 742 "from continue startup (timeout)");
757} 743}
758 744
759/** 745/**
@@ -765,8 +751,7 @@ create_topology ()
765 * @param emsg non-null on failure 751 * @param emsg non-null on failure
766 */ 752 */
767void 753void
768hostkey_callback (void *cls, 754hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
769 const struct GNUNET_PeerIdentity *id,
770 struct GNUNET_TESTING_Daemon *d, const char *emsg) 755 struct GNUNET_TESTING_Daemon *d, const char *emsg)
771{ 756{
772 if (emsg != NULL) 757 if (emsg != NULL)
@@ -777,8 +762,8 @@ hostkey_callback (void *cls,
777 762
778#if VERBOSE > 1 763#if VERBOSE > 1
779 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 764 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
780 "Hostkey (%d/%d) created for peer `%s'\n", 765 "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left,
781 num_peers - peers_left, num_peers, GNUNET_i2s (id)); 766 num_peers, GNUNET_i2s (id));
782#endif 767#endif
783 768
784 769
@@ -792,9 +777,9 @@ hostkey_callback (void *cls,
792 GNUNET_SCHEDULER_cancel (die_task); 777 GNUNET_SCHEDULER_cancel (die_task);
793 /* Set up task in case topology creation doesn't finish 778 /* Set up task in case topology creation doesn't finish
794 * within a reasonable amount of time */ 779 * within a reasonable amount of time */
795 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 780 die_task =
796 &end_badly, 781 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
797 "from create_topology"); 782 "from create_topology");
798 GNUNET_SCHEDULER_add_now (&create_topology, NULL); 783 GNUNET_SCHEDULER_add_now (&create_topology, NULL);
799 ok = 0; 784 ok = 0;
800 } 785 }
@@ -802,9 +787,8 @@ hostkey_callback (void *cls,
802 787
803 788
804static void 789static void
805run (void *cls, 790run (void *cls, char *const *args, const char *cfgfile,
806 char *const *args, 791 const struct GNUNET_CONFIGURATION_Handle *cfg)
807 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
808{ 792{
809 char *topology_str; 793 char *topology_str;
810 char *connect_topology_str; 794 char *connect_topology_str;
@@ -962,9 +946,9 @@ check ()
962 GNUNET_GETOPT_OPTION_END 946 GNUNET_GETOPT_OPTION_END
963 }; 947 };
964 /* Run the run function as a new program */ 948 /* Run the run function as a new program */
965 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 949 ret =
966 argv, "test-dht-multipeer", "nohelp", 950 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
967 options, &run, &ok); 951 "test-dht-multipeer", "nohelp", options, &run, &ok);
968 if (ret != GNUNET_OK) 952 if (ret != GNUNET_OK)
969 { 953 {
970 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 954 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,