diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index ef7a031c5..ef90fa79c 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -347,12 +347,12 @@ in_arr (const struct GNUNET_PeerIdentity *array, | |||
347 | * Get random peer from the gossip list. | 347 | * Get random peer from the gossip list. |
348 | */ | 348 | */ |
349 | struct GNUNET_PeerIdentity * | 349 | struct GNUNET_PeerIdentity * |
350 | get_rand_peer(const struct GNUNET_PeerIdentity *peer_list, unsigned int list_size) | 350 | get_rand_peer (const struct GNUNET_PeerIdentity *peer_list, unsigned int list_size) |
351 | { | 351 | { |
352 | uint64_t r_index; | 352 | uint64_t r_index; |
353 | struct GNUNET_PeerIdentity *peer; | 353 | struct GNUNET_PeerIdentity *peer; |
354 | 354 | ||
355 | peer = GNUNET_new(struct GNUNET_PeerIdentity); | 355 | peer = GNUNET_new (struct GNUNET_PeerIdentity); |
356 | // FIXME if we have only NULL in gossip list this will block | 356 | // FIXME if we have only NULL in gossip list this will block |
357 | // but then we might have a problem nevertheless | 357 | // but then we might have a problem nevertheless |
358 | 358 | ||
@@ -363,7 +363,7 @@ get_rand_peer(const struct GNUNET_PeerIdentity *peer_list, unsigned int list_siz | |||
363 | * Choose the r_index of the peer we want to return | 363 | * Choose the r_index of the peer we want to return |
364 | * at random from the interval of the gossip list | 364 | * at random from the interval of the gossip list |
365 | */ | 365 | */ |
366 | r_index = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, | 366 | r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, |
367 | list_size); | 367 | list_size); |
368 | 368 | ||
369 | *peer = peer_list[r_index]; | 369 | *peer = peer_list[r_index]; |
@@ -480,7 +480,7 @@ T_relative_avg (const struct GNUNET_TIME_Relative *rel_array, uint64_t arr_size) | |||
480 | * Wrapper around _sampler_resize() | 480 | * Wrapper around _sampler_resize() |
481 | */ | 481 | */ |
482 | void | 482 | void |
483 | resize_wrapper() | 483 | resize_wrapper () |
484 | { | 484 | { |
485 | uint64_t bigger_size; | 485 | uint64_t bigger_size; |
486 | 486 | ||
@@ -510,7 +510,7 @@ resize_wrapper() | |||
510 | * accordingly. | 510 | * accordingly. |
511 | */ | 511 | */ |
512 | void | 512 | void |
513 | nse_callback(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev) | 513 | nse_callback (void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev) |
514 | { | 514 | { |
515 | double estimate; | 515 | double estimate; |
516 | //double scale; // TODO this might go gloabal/config | 516 | //double scale; // TODO this might go gloabal/config |
@@ -555,7 +555,7 @@ void client_respond (void *cls, | |||
555 | GNUNET_MESSAGE_TYPE_RPS_CS_REPLY); | 555 | GNUNET_MESSAGE_TYPE_RPS_CS_REPLY); |
556 | out_msg->num_peers = GNUNET_htonll (num_peers); | 556 | out_msg->num_peers = GNUNET_htonll (num_peers); |
557 | 557 | ||
558 | memcpy(&out_msg[1], | 558 | memcpy (&out_msg[1], |
559 | ids, | 559 | ids, |
560 | num_peers * sizeof (struct GNUNET_PeerIdentity)); | 560 | num_peers * sizeof (struct GNUNET_PeerIdentity)); |
561 | GNUNET_free (ids); | 561 | GNUNET_free (ids); |
@@ -583,7 +583,7 @@ handle_client_request (void *cls, | |||
583 | struct GNUNET_SERVER_Client *client, | 583 | struct GNUNET_SERVER_Client *client, |
584 | const struct GNUNET_MessageHeader *message) | 584 | const struct GNUNET_MessageHeader *message) |
585 | { | 585 | { |
586 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Client requested (a) random peer(s).\n"); | 586 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Client requested (a) random peer(s).\n"); |
587 | 587 | ||
588 | struct GNUNET_RPS_CS_RequestMessage *msg; | 588 | struct GNUNET_RPS_CS_RequestMessage *msg; |
589 | uint64_t num_peers; | 589 | uint64_t num_peers; |
@@ -608,7 +608,7 @@ handle_client_request (void *cls, | |||
608 | GNUNET_TIME_relative_divide (round_interval, 2)); | 608 | GNUNET_TIME_relative_divide (round_interval, 2)); |
609 | sampler_size_client_need = max_round_duration.rel_value_us / request_rate.rel_value_us; | 609 | sampler_size_client_need = max_round_duration.rel_value_us / request_rate.rel_value_us; |
610 | 610 | ||
611 | resize_wrapper(); | 611 | resize_wrapper (); |
612 | } | 612 | } |
613 | last_request = GNUNET_TIME_absolute_get (); | 613 | last_request = GNUNET_TIME_absolute_get (); |
614 | 614 | ||
@@ -803,7 +803,7 @@ handle_peer_pull_reply (void *cls, | |||
803 | static void | 803 | static void |
804 | do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 804 | do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
805 | { | 805 | { |
806 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round\n"); | 806 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round\n"); |
807 | 807 | ||
808 | uint64_t i; | 808 | uint64_t i; |
809 | //unsigned int *n_arr; | 809 | //unsigned int *n_arr; |
@@ -823,11 +823,11 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
823 | * in essence get random peers with consumption */ | 823 | * in essence get random peers with consumption */ |
824 | 824 | ||
825 | /* Send PUSHes */ | 825 | /* Send PUSHes */ |
826 | //n_arr = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) gossip_list_size); | 826 | //n_arr = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) gossip_list_size); |
827 | n_peers = round (alpha * gossip_list_size); | 827 | n_peers = round (alpha * gossip_list_size); |
828 | if (0 == n_peers) | 828 | if (0 == n_peers) |
829 | n_peers = 1; | 829 | n_peers = 1; |
830 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Going to send pushes to %u (%f * %u) peers.\n", | 830 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to send pushes to %u (%f * %u) peers.\n", |
831 | n_peers, alpha, gossip_list_size); | 831 | n_peers, alpha, gossip_list_size); |
832 | for ( i = 0 ; i < n_peers ; i++ ) | 832 | for ( i = 0 ; i < n_peers ; i++ ) |
833 | { | 833 | { |
@@ -845,7 +845,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
845 | 845 | ||
846 | 846 | ||
847 | /* Send PULL requests */ | 847 | /* Send PULL requests */ |
848 | //n_arr = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) sampler_list->size); | 848 | //n_arr = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) sampler_list->size); |
849 | n_peers = round (beta * gossip_list_size); | 849 | n_peers = round (beta * gossip_list_size); |
850 | if (0 == n_peers) | 850 | if (0 == n_peers) |
851 | n_peers = 1; | 851 | n_peers = 1; |
@@ -873,7 +873,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
873 | push_list_size != 0 && | 873 | push_list_size != 0 && |
874 | pull_list_size != 0 ) | 874 | pull_list_size != 0 ) |
875 | { | 875 | { |
876 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Update of the gossip list. ()\n"); | 876 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Update of the gossip list. ()\n"); |
877 | 877 | ||
878 | uint64_t first_border; | 878 | uint64_t first_border; |
879 | uint64_t second_border; | 879 | uint64_t second_border; |
@@ -890,7 +890,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
890 | // TODO change the in_flags accordingly | 890 | // TODO change the in_flags accordingly |
891 | } | 891 | } |
892 | 892 | ||
893 | second_border = first_border + round(beta * gossip_list_size); | 893 | second_border = first_border + round (beta * gossip_list_size); |
894 | for ( i = first_border ; i < second_border ; i++ ) | 894 | for ( i = first_border ; i < second_border ; i++ ) |
895 | { | 895 | { |
896 | /* Update gossip list with peers received through PULLs */ | 896 | /* Update gossip list with peers received through PULLs */ |
@@ -911,7 +911,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
911 | } | 911 | } |
912 | else | 912 | else |
913 | { | 913 | { |
914 | LOG(GNUNET_ERROR_TYPE_DEBUG, "No update of the gossip list. ()\n"); | 914 | LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the gossip list. ()\n"); |
915 | } | 915 | } |
916 | // TODO independent of that also get some peers from CADET_get_peers()? | 916 | // TODO independent of that also get some peers from CADET_get_peers()? |
917 | 917 | ||
@@ -1041,9 +1041,9 @@ init_peer_cb (void *cls, | |||
1041 | { | 1041 | { |
1042 | if (ipc->i < gossip_list_size) | 1042 | if (ipc->i < gossip_list_size) |
1043 | { | 1043 | { |
1044 | memcpy(&gossip_list[ipc->i], | 1044 | memcpy (&gossip_list[ipc->i], |
1045 | RPS_sampler_get_n_rand_peers_ (1), | 1045 | RPS_sampler_get_n_rand_peers_ (1), |
1046 | (gossip_list_size - ipc->i) * sizeof(struct GNUNET_PeerIdentity)); | 1046 | (gossip_list_size - ipc->i) * sizeof (struct GNUNET_PeerIdentity)); |
1047 | } | 1047 | } |
1048 | rps_start (ipc->server); | 1048 | rps_start (ipc->server); |
1049 | GNUNET_free (ipc); | 1049 | GNUNET_free (ipc); |
@@ -1061,7 +1061,7 @@ static void | |||
1061 | shutdown_task (void *cls, | 1061 | shutdown_task (void *cls, |
1062 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1062 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
1063 | { | 1063 | { |
1064 | LOG(GNUNET_ERROR_TYPE_DEBUG, "RPS is going down\n"); | 1064 | LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS is going down\n"); |
1065 | 1065 | ||
1066 | if ( NULL != do_round_task ) | 1066 | if ( NULL != do_round_task ) |
1067 | { | 1067 | { |
@@ -1110,13 +1110,13 @@ handle_inbound_channel (void *cls, | |||
1110 | { | 1110 | { |
1111 | struct peer_context *ctx; | 1111 | struct peer_context *ctx; |
1112 | 1112 | ||
1113 | LOG(GNUNET_ERROR_TYPE_DEBUG, "New channel was established to us (Peer %s).\n", GNUNET_i2s(initiator)); | 1113 | LOG (GNUNET_ERROR_TYPE_DEBUG, "New channel was established to us (Peer %s).\n", GNUNET_i2s (initiator)); |
1114 | 1114 | ||
1115 | GNUNET_assert( NULL != channel ); | 1115 | GNUNET_assert ( NULL != channel ); |
1116 | 1116 | ||
1117 | // we might not even store the from_channel | 1117 | // we might not even store the from_channel |
1118 | 1118 | ||
1119 | ctx = get_peer_ctx(peer_map, initiator); | 1119 | ctx = get_peer_ctx (peer_map, initiator); |
1120 | if (NULL != ctx->from_channel) | 1120 | if (NULL != ctx->from_channel) |
1121 | { | 1121 | { |
1122 | ctx->from_channel = channel; | 1122 | ctx->from_channel = channel; |
@@ -1140,12 +1140,12 @@ handle_inbound_channel (void *cls, | |||
1140 | * @param channel_ctx The context associated with this channel | 1140 | * @param channel_ctx The context associated with this channel |
1141 | */ | 1141 | */ |
1142 | static void | 1142 | static void |
1143 | cleanup_channel(void *cls, | 1143 | cleanup_channel (void *cls, |
1144 | const struct GNUNET_CADET_Channel *channel, | 1144 | const struct GNUNET_CADET_Channel *channel, |
1145 | void *channel_ctx) | 1145 | void *channel_ctx) |
1146 | { | 1146 | { |
1147 | struct GNUNET_PeerIdentity *peer; | 1147 | struct GNUNET_PeerIdentity *peer; |
1148 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Channel to remote peer was destroyed.\n"); | 1148 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel to remote peer was destroyed.\n"); |
1149 | 1149 | ||
1150 | peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info ( | 1150 | peer = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info ( |
1151 | (struct GNUNET_CADET_Channel *) channel, GNUNET_CADET_OPTION_PEER); | 1151 | (struct GNUNET_CADET_Channel *) channel, GNUNET_CADET_OPTION_PEER); |
@@ -1171,11 +1171,11 @@ rps_start (struct GNUNET_SERVER_Handle *server) | |||
1171 | GNUNET_SERVER_disconnect_notify (server, | 1171 | GNUNET_SERVER_disconnect_notify (server, |
1172 | &handle_client_disconnect, | 1172 | &handle_client_disconnect, |
1173 | NULL); | 1173 | NULL); |
1174 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Ready to receive requests from clients\n"); | 1174 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Ready to receive requests from clients\n"); |
1175 | 1175 | ||
1176 | 1176 | ||
1177 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); | 1177 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); |
1178 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); | 1178 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); |
1179 | 1179 | ||
1180 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1180 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
1181 | &shutdown_task, | 1181 | &shutdown_task, |
@@ -1199,7 +1199,7 @@ run (void *cls, | |||
1199 | // - seems to work as expected | 1199 | // - seems to work as expected |
1200 | GNUNET_log_setup ("rps", GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), NULL); | 1200 | GNUNET_log_setup ("rps", GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), NULL); |
1201 | 1201 | ||
1202 | LOG(GNUNET_ERROR_TYPE_DEBUG, "RPS started\n"); | 1202 | LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS started\n"); |
1203 | 1203 | ||
1204 | struct init_peer_cls *ipc; | 1204 | struct init_peer_cls *ipc; |
1205 | 1205 | ||
@@ -1210,7 +1210,7 @@ run (void *cls, | |||
1210 | own_identity = GNUNET_new (struct GNUNET_PeerIdentity); | 1210 | own_identity = GNUNET_new (struct GNUNET_PeerIdentity); |
1211 | GNUNET_CRYPTO_get_peer_identity (cfg, own_identity); // TODO check return value | 1211 | GNUNET_CRYPTO_get_peer_identity (cfg, own_identity); // TODO check return value |
1212 | GNUNET_assert (NULL != own_identity); | 1212 | GNUNET_assert (NULL != own_identity); |
1213 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Own identity is %s (at %p).\n", GNUNET_i2s(own_identity), own_identity); | 1213 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Own identity is %s (at %p).\n", GNUNET_i2s (own_identity), own_identity); |
1214 | 1214 | ||
1215 | 1215 | ||
1216 | /* Get time interval from the configuration */ | 1216 | /* Get time interval from the configuration */ |
@@ -1219,7 +1219,7 @@ run (void *cls, | |||
1219 | &round_interval)) | 1219 | &round_interval)) |
1220 | { | 1220 | { |
1221 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to read ROUNDINTERVAL from config\n"); | 1221 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to read ROUNDINTERVAL from config\n"); |
1222 | GNUNET_SCHEDULER_shutdown(); | 1222 | GNUNET_SCHEDULER_shutdown (); |
1223 | return; | 1223 | return; |
1224 | } | 1224 | } |
1225 | 1225 | ||
@@ -1256,9 +1256,9 @@ run (void *cls, | |||
1256 | "ALPHA", | 1256 | "ALPHA", |
1257 | &alpha)) | 1257 | &alpha)) |
1258 | { | 1258 | { |
1259 | LOG(GNUNET_ERROR_TYPE_DEBUG, "No ALPHA specified in the config\n"); | 1259 | LOG (GNUNET_ERROR_TYPE_DEBUG, "No ALPHA specified in the config\n"); |
1260 | } | 1260 | } |
1261 | LOG(GNUNET_ERROR_TYPE_DEBUG, "ALPHA is %f\n", alpha); | 1261 | LOG (GNUNET_ERROR_TYPE_DEBUG, "ALPHA is %f\n", alpha); |
1262 | 1262 | ||
1263 | /* Get beta from the configuration */ | 1263 | /* Get beta from the configuration */ |
1264 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_float (cfg, "RPS", | 1264 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_float (cfg, "RPS", |