aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-01-22 21:34:47 +0000
committerJulius Bünger <buenger@mytum.de>2015-01-22 21:34:47 +0000
commit8c0022803d0a2f74b8f8e3fbbbb9afddf2b621bc (patch)
tree52a5694956c4aeed28d3c60fa4a7fd268d242b50 /src
parent2a51624aec1b1a5bc464853c5446f628fa3b99f0 (diff)
downloadgnunet-8c0022803d0a2f74b8f8e3fbbbb9afddf2b621bc.tar.gz
gnunet-8c0022803d0a2f74b8f8e3fbbbb9afddf2b621bc.zip
improved selection of peers for pushing
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 108cdd00c..58c986247 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -231,16 +231,12 @@ static unsigned int sampler_size_est_need;
231/** 231/**
232 * Percentage of total peer number in the gossip list 232 * Percentage of total peer number in the gossip list
233 * to send random PUSHes to 233 * to send random PUSHes to
234 *
235 * TODO do not read from configuration
236 */ 234 */
237static float alpha; 235static float alpha;
238 236
239/** 237/**
240 * Percentage of total peer number in the gossip list 238 * Percentage of total peer number in the gossip list
241 * to send random PULLs to 239 * to send random PULLs to
242 *
243 * TODO do not read from configuration
244 */ 240 */
245static float beta; 241static float beta;
246 242
@@ -702,7 +698,6 @@ insert_in_sampler_scheduled (const struct PeerContext *peer_ctx)
702} 698}
703 699
704 700
705
706/** 701/**
707 * Wrapper around #RPS_sampler_resize() 702 * Wrapper around #RPS_sampler_resize()
708 */ 703 */
@@ -1064,7 +1059,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1064 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round\n"); 1059 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round\n");
1065 1060
1066 uint32_t i; 1061 uint32_t i;
1067 //unsigned int *n_arr; 1062 unsigned int *permut;
1068 unsigned int n_peers; /* Number of peers we send pushes/pulls to */ 1063 unsigned int n_peers; /* Number of peers we send pushes/pulls to */
1069 struct GNUNET_MQ_Envelope *ev; 1064 struct GNUNET_MQ_Envelope *ev;
1070 const struct GNUNET_PeerIdentity *peer; 1065 const struct GNUNET_PeerIdentity *peer;
@@ -1079,21 +1074,23 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1079 * in essence get random peers with consumption */ 1074 * in essence get random peers with consumption */
1080 1075
1081 /* Send PUSHes */ 1076 /* Send PUSHes */
1082 //n_arr = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) gossip_list_size); 1077 if (0 < gossip_list_size)
1083 if (0 != gossip_list_size)
1084 { 1078 {
1085 n_peers = round (alpha * gossip_list_size); 1079 permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG,
1086 if (0 == n_peers) 1080 (unsigned int) gossip_list_size);
1087 n_peers = 1; 1081 if (0 != gossip_list_size)
1088 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to send pushes to %u (%f * %u) peers.\n",
1089 n_peers, alpha, gossip_list_size);
1090 for ( i = 0 ; i < n_peers ; i++ )
1091 { 1082 {
1092 // TODO 1083 n_peers = round (alpha * gossip_list_size);
1093 peer = get_rand_peer_ignore_list (gossip_list, gossip_list_size, 1084 if (0 == n_peers)
1094 NULL, 0); 1085 n_peers = 1;
1095 if (NULL != peer) 1086 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to send pushes to %u (%f * %u) peers.\n",
1087 n_peers, alpha, gossip_list_size);
1088 for ( i = 0 ; i < n_peers ; i++ )
1096 { 1089 {
1090 // TODO
1091 //peer = get_rand_peer_ignore_list (gossip_list, gossip_list_size,
1092 // NULL, 0);
1093 peer = &gossip_list[permut[i]];
1097 if (own_identity != peer) // TODO 1094 if (own_identity != peer) // TODO
1098 { // FIXME if this fails schedule/loop this for later 1095 { // FIXME if this fails schedule/loop this for later
1099 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s (peer)); 1096 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending PUSH to peer %s of gossiped list.\n", GNUNET_i2s (peer));
@@ -1109,7 +1106,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1109 1106
1110 1107
1111 /* Send PULL requests */ 1108 /* Send PULL requests */
1112 //n_arr = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) sampler_list->size); 1109 //permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_STRONG, (unsigned int) sampler_list->size);
1113 if (0 != gossip_list_size) 1110 if (0 != gossip_list_size)
1114 { 1111 {
1115 n_peers = round (beta * gossip_list_size); 1112 n_peers = round (beta * gossip_list_size);