diff options
author | Julius Bünger <buenger@mytum.de> | 2015-03-27 12:40:50 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-03-27 12:40:50 +0000 |
commit | 4dffb204f9cac851bb280530a10aa84a4168cda2 (patch) | |
tree | 9cf44cb218a826666eaf3b6d66288ef3bbb3e641 /src | |
parent | b19785784087d703576eb7ffd57ce24e2a462e31 (diff) | |
download | gnunet-4dffb204f9cac851bb280530a10aa84a4168cda2.tar.gz gnunet-4dffb204f9cac851bb280530a10aa84a4168cda2.zip |
-restructured handling peers from 'external sources'
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 97 |
1 files changed, 56 insertions, 41 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index b8f87a39a..f2d98291f 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -1136,6 +1136,56 @@ send_pull_reply (const struct GNUNET_PeerIdentity *peer_id, | |||
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | 1138 | ||
1139 | /** | ||
1140 | * This function is called on new peer_ids from 'external' sources | ||
1141 | * (client seed, cadet get_peers(), ...) | ||
1142 | * | ||
1143 | * @param peer_id the new peer_id | ||
1144 | */ | ||
1145 | static void | ||
1146 | new_peer_id (const struct GNUNET_PeerIdentity *peer_id) | ||
1147 | { | ||
1148 | struct PeerOutstandingOp out_op; | ||
1149 | struct PeerContext *peer_ctx; | ||
1150 | |||
1151 | if (NULL != peer_id | ||
1152 | && 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer_id)) | ||
1153 | { | ||
1154 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1155 | "Got new peer %s (at %p) from some external source (gossip_list_size: %u)\n", | ||
1156 | GNUNET_i2s (peer_id), peer_id, gossip_list_size); | ||
1157 | |||
1158 | peer_ctx = get_peer_ctx (peer_map, peer_id); | ||
1159 | if (GNUNET_YES != get_peer_flag (peer_ctx, VALID)) | ||
1160 | { | ||
1161 | if (GNUNET_NO == insert_in_sampler_scheduled (peer_ctx)) | ||
1162 | { | ||
1163 | out_op.op = insert_in_sampler; | ||
1164 | out_op.op_cls = NULL; | ||
1165 | GNUNET_array_append (peer_ctx->outstanding_ops, | ||
1166 | peer_ctx->num_outstanding_ops, | ||
1167 | out_op); | ||
1168 | } | ||
1169 | |||
1170 | if (GNUNET_NO == insert_in_gossip_list_scheduled (peer_ctx)) | ||
1171 | { | ||
1172 | out_op.op = insert_in_gossip_list; | ||
1173 | out_op.op_cls = NULL; | ||
1174 | GNUNET_array_append (peer_ctx->outstanding_ops, | ||
1175 | peer_ctx->num_outstanding_ops, | ||
1176 | out_op); | ||
1177 | } | ||
1178 | |||
1179 | /* Trigger livelyness test on peer */ | ||
1180 | check_peer_live (peer_ctx); | ||
1181 | } | ||
1182 | // else...? | ||
1183 | |||
1184 | // send push/pull to each of those peers? | ||
1185 | } | ||
1186 | } | ||
1187 | |||
1188 | |||
1139 | /*********************************************************************** | 1189 | /*********************************************************************** |
1140 | * /Util functions | 1190 | * /Util functions |
1141 | ***********************************************************************/ | 1191 | ***********************************************************************/ |
@@ -1327,11 +1377,13 @@ handle_client_seed (void *cls, | |||
1327 | i, | 1377 | i, |
1328 | GNUNET_i2s (&peers[i])); | 1378 | GNUNET_i2s (&peers[i])); |
1329 | 1379 | ||
1330 | RPS_sampler_update (prot_sampler, &peers[i]); | 1380 | new_peer_id (&peers[i]); |
1331 | RPS_sampler_update (client_sampler, &peers[i]); | 1381 | |
1382 | //RPS_sampler_update (prot_sampler, &peers[i]); | ||
1383 | //RPS_sampler_update (client_sampler, &peers[i]); | ||
1332 | } | 1384 | } |
1333 | 1385 | ||
1334 | //GNUNET_free (peers); | 1386 | ////GNUNET_free (peers); |
1335 | 1387 | ||
1336 | GNUNET_SERVER_receive_done (client, | 1388 | GNUNET_SERVER_receive_done (client, |
1337 | GNUNET_OK); | 1389 | GNUNET_OK); |
@@ -2045,44 +2097,7 @@ init_peer_cb (void *cls, | |||
2045 | unsigned int best_path) // "How long is the best path? | 2097 | unsigned int best_path) // "How long is the best path? |
2046 | // (0 = unknown, 1 = ourselves, 2 = neighbor)" | 2098 | // (0 = unknown, 1 = ourselves, 2 = neighbor)" |
2047 | { | 2099 | { |
2048 | struct PeerOutstandingOp out_op; | 2100 | new_peer_id (peer); |
2049 | struct PeerContext *peer_ctx; | ||
2050 | |||
2051 | if (NULL != peer | ||
2052 | && 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, peer)) | ||
2053 | { | ||
2054 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2055 | "Got peer %s (at %p) from CADET (gossip_list_size: %u)\n", | ||
2056 | GNUNET_i2s (peer), peer, gossip_list_size); | ||
2057 | |||
2058 | // maybe create a function for that | ||
2059 | peer_ctx = get_peer_ctx (peer_map, peer); | ||
2060 | if (GNUNET_YES != get_peer_flag (peer_ctx, VALID)) | ||
2061 | { | ||
2062 | if (GNUNET_NO == insert_in_sampler_scheduled (peer_ctx)) | ||
2063 | { | ||
2064 | out_op.op = insert_in_sampler; | ||
2065 | out_op.op_cls = NULL; | ||
2066 | GNUNET_array_append (peer_ctx->outstanding_ops, | ||
2067 | peer_ctx->num_outstanding_ops, | ||
2068 | out_op); | ||
2069 | } | ||
2070 | |||
2071 | if (GNUNET_NO == insert_in_gossip_list_scheduled (peer_ctx)) | ||
2072 | { | ||
2073 | out_op.op = insert_in_gossip_list; | ||
2074 | out_op.op_cls = NULL; | ||
2075 | GNUNET_array_append (peer_ctx->outstanding_ops, | ||
2076 | peer_ctx->num_outstanding_ops, | ||
2077 | out_op); | ||
2078 | } | ||
2079 | |||
2080 | /* Trigger livelyness test on peer */ | ||
2081 | check_peer_live (peer_ctx); | ||
2082 | } | ||
2083 | |||
2084 | // send push/pull to each of those peers? | ||
2085 | } | ||
2086 | } | 2101 | } |
2087 | 2102 | ||
2088 | 2103 | ||