diff options
author | Julius Bünger <buenger@mytum.de> | 2015-01-08 00:31:15 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-01-08 00:31:15 +0000 |
commit | a6dc8c0e8778b15acbd1dee5aab4dbf23eeebf38 (patch) | |
tree | 5df16ce2c1576d02ef3449d6f96b82e875a2d7d4 /src/rps | |
parent | 676fbb0f20ca8372a7c76082c879ae5a3af3971d (diff) | |
download | gnunet-a6dc8c0e8778b15acbd1dee5aab4dbf23eeebf38.tar.gz gnunet-a6dc8c0e8778b15acbd1dee5aab4dbf23eeebf38.zip |
randomised scheduling of next round, cosmetic changes
Diffstat (limited to 'src/rps')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 8aef30a9f..287ccf065 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -656,7 +656,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
656 | struct GNUNET_MQ_Handle *mq; | 656 | struct GNUNET_MQ_Handle *mq; |
657 | 657 | ||
658 | // TODO print lists, ... | 658 | // TODO print lists, ... |
659 | // TODO rendomise and spread calls herein over time | 659 | // TODO randomise and spread calls herein over time |
660 | 660 | ||
661 | 661 | ||
662 | /* Would it make sense to have one shuffeled gossip list and then | 662 | /* Would it make sense to have one shuffeled gossip list and then |
@@ -672,23 +672,17 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
672 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Going to send pushes to %u (%f * %u) peers.\n", | 672 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Going to send pushes to %u (%f * %u) peers.\n", |
673 | n_peers, alpha, gossip_list_size); | 673 | n_peers, alpha, gossip_list_size); |
674 | for ( i = 0 ; i < n_peers ; i++ ) | 674 | for ( i = 0 ; i < n_peers ; i++ ) |
675 | { // TODO compute length | 675 | { |
676 | peer = get_rand_peer (gossip_list, gossip_list_size); | 676 | peer = get_rand_peer (gossip_list, gossip_list_size); |
677 | if (own_identity != peer) | 677 | if (own_identity != peer) |
678 | { // FIXME if this fails schedule/loop this for later | 678 | { // FIXME if this fails schedule/loop this for later |
679 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s (peer)); | 679 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s (peer)); |
680 | 680 | ||
681 | ev = GNUNET_MQ_msg (push_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); | 681 | ev = GNUNET_MQ_msg (push_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PUSH); |
682 | //ev = GNUNET_MQ_msg_extra(); | ||
683 | /* TODO Compute proof of work here | ||
684 | push_msg; */ | ||
685 | //push_msg->placeholder = 0; | ||
686 | push_msg = NULL; | 682 | push_msg = NULL; |
687 | // FIXME sometimes it returns a pointer to a freed mq | 683 | // FIXME sometimes it returns a pointer to a freed mq |
688 | mq = get_mq (peer_map, peer); | 684 | mq = get_mq (peer_map, peer); |
689 | GNUNET_MQ_send (mq, ev); | 685 | GNUNET_MQ_send (mq, ev); |
690 | |||
691 | // modify in_flags of respective peer? | ||
692 | } | 686 | } |
693 | } | 687 | } |
694 | 688 | ||
@@ -701,18 +695,16 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
701 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to send pulls to %u (%f * %u) peers.\n", | 695 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to send pulls to %u (%f * %u) peers.\n", |
702 | n_peers, beta, gossip_list_size); | 696 | n_peers, beta, gossip_list_size); |
703 | for ( i = 0 ; i < n_peers ; i++ ) | 697 | for ( i = 0 ; i < n_peers ; i++ ) |
704 | { // TODO compute length | 698 | { |
705 | peer = get_rand_peer (gossip_list, gossip_list_size); | 699 | peer = get_rand_peer (gossip_list, gossip_list_size); |
706 | if (own_identity != peer) | 700 | if (own_identity != peer) |
707 | { // FIXME if this fails schedule/loop this for later | 701 | { // FIXME if this fails schedule/loop this for later |
708 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PULL request to peer %s of gossiped list.\n", GNUNET_i2s (peer)); | 702 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PULL request to peer %s of gossiped list.\n", GNUNET_i2s (peer)); |
709 | 703 | ||
710 | ev = GNUNET_MQ_msg (pull_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); | 704 | ev = GNUNET_MQ_msg (pull_msg, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST); |
711 | //pull_msg->placeholder = 0; | ||
712 | pull_msg = NULL; | 705 | pull_msg = NULL; |
713 | mq = get_mq (peer_map, peer); | 706 | mq = get_mq (peer_map, peer); |
714 | GNUNET_MQ_send (mq, ev); | 707 | GNUNET_MQ_send (mq, ev); |
715 | // modify in_flags of respective peer? | ||
716 | } | 708 | } |
717 | } | 709 | } |
718 | 710 | ||
@@ -786,6 +778,18 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
786 | GNUNET_array_grow (push_list, push_list_size, 0); | 778 | GNUNET_array_grow (push_list, push_list_size, 0); |
787 | GNUNET_array_grow (pull_list, pull_list_size, 0); | 779 | GNUNET_array_grow (pull_list, pull_list_size, 0); |
788 | 780 | ||
781 | struct GNUNET_TIME_Relative time_next_round; | ||
782 | struct GNUNET_TIME_Relative half_round_interval; | ||
783 | unsigned int rand_delay; | ||
784 | |||
785 | do | ||
786 | { | ||
787 | half_round_interval = GNUNET_TIME_relative_divide (round_interval, 2); | ||
788 | rand_delay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT_MAX/10); | ||
789 | time_next_round = GNUNET_TIME_relative_multiply (time_next_round, rand_delay); | ||
790 | time_next_round = GNUNET_TIME_relative_divide (time_next_round, UINT_MAX/10); | ||
791 | time_next_round = GNUNET_TIME_relative_add (time_next_round, half_round_interval); | ||
792 | } while (GNUNET_TIME_FOREVER_REL != time_next_round); | ||
789 | 793 | ||
790 | /* Schedule next round */ | 794 | /* Schedule next round */ |
791 | do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, &do_round, NULL); | 795 | do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, &do_round, NULL); |