diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-03-21 14:55:19 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-03-21 14:55:19 +0000 |
commit | e99e3158a48afb48f7e75eac9e5eeca1e5f89b78 (patch) | |
tree | e469febf1ab099a686a1530e0d30dd75c18cbee6 /src/consensus | |
parent | bb9075688c6ceef12f3cc762cf1da130b7ca73d2 (diff) | |
download | gnunet-e99e3158a48afb48f7e75eac9e5eeca1e5f89b78.tar.gz gnunet-e99e3158a48afb48f7e75eac9e5eeca1e5f89b78.zip |
-notes
Diffstat (limited to 'src/consensus')
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 41 | ||||
-rw-r--r-- | src/consensus/ibf.c | 4 |
2 files changed, 21 insertions, 24 deletions
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 4b69c5327..7a9eba671 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c | |||
@@ -1008,7 +1008,7 @@ is_premature_strata_message (const struct ConsensusSession *session, const struc | |||
1008 | static int | 1008 | static int |
1009 | handle_p2p_strata (struct ConsensusPeerInformation *cpi, const struct StrataMessage *strata_msg) | 1009 | handle_p2p_strata (struct ConsensusPeerInformation *cpi, const struct StrataMessage *strata_msg) |
1010 | { | 1010 | { |
1011 | int i; | 1011 | int i; // unsigned? |
1012 | unsigned int diff; | 1012 | unsigned int diff; |
1013 | void *buf; | 1013 | void *buf; |
1014 | size_t size; | 1014 | size_t size; |
@@ -1036,7 +1036,7 @@ handle_p2p_strata (struct ConsensusPeerInformation *cpi, const struct StrataMess | |||
1036 | cpi->apparent_round = strata_msg->round; | 1036 | cpi->apparent_round = strata_msg->round; |
1037 | 1037 | ||
1038 | size = ntohs (strata_msg->header.size); | 1038 | size = ntohs (strata_msg->header.size); |
1039 | buf = (void *) &strata_msg[1]; | 1039 | buf = (void *) &strata_msg[1]; // FIXME: do NOT cast away 'const'! |
1040 | for (i = 0; i < STRATA_COUNT; i++) | 1040 | for (i = 0; i < STRATA_COUNT; i++) |
1041 | { | 1041 | { |
1042 | int res; | 1042 | int res; |
@@ -1088,7 +1088,7 @@ handle_p2p_ibf (struct ConsensusPeerInformation *cpi, const struct DifferenceDig | |||
1088 | /* FIXME: find out if we're still expecting the same ibf! */ | 1088 | /* FIXME: find out if we're still expecting the same ibf! */ |
1089 | 1089 | ||
1090 | cpi->apparent_round = cpi->session->current_round; | 1090 | cpi->apparent_round = cpi->session->current_round; |
1091 | 1091 | // FIXME: check header.size >= sizeof (DD) | |
1092 | num_buckets = (ntohs (digest->header.size) - (sizeof *digest)) / IBF_BUCKET_SIZE; | 1092 | num_buckets = (ntohs (digest->header.size) - (sizeof *digest)) / IBF_BUCKET_SIZE; |
1093 | switch (cpi->ibf_state) | 1093 | switch (cpi->ibf_state) |
1094 | { | 1094 | { |
@@ -1132,7 +1132,7 @@ handle_p2p_ibf (struct ConsensusPeerInformation *cpi, const struct DifferenceDig | |||
1132 | if (NULL == cpi->ibf) | 1132 | if (NULL == cpi->ibf) |
1133 | cpi->ibf = ibf_create (1 << cpi->ibf_order, STRATA_HASH_NUM, 0); | 1133 | cpi->ibf = ibf_create (1 << cpi->ibf_order, STRATA_HASH_NUM, 0); |
1134 | 1134 | ||
1135 | buf = (void *) &digest[1]; | 1135 | buf = (void *) &digest[1]; // FIXME: digest is supposed to be READ ONLY! |
1136 | ibf_read_slice (&buf, NULL, cpi->ibf_bucket_counter, num_buckets, cpi->ibf); | 1136 | ibf_read_slice (&buf, NULL, cpi->ibf_bucket_counter, num_buckets, cpi->ibf); |
1137 | 1137 | ||
1138 | cpi->ibf_bucket_counter += num_buckets; | 1138 | cpi->ibf_bucket_counter += num_buckets; |
@@ -1261,24 +1261,21 @@ handle_p2p_hello (struct IncomingSocket *inc, const struct ConsensusHello *hello | |||
1261 | { | 1261 | { |
1262 | /* FIXME: session might not exist yet. create an uninhabited session and wait for a client */ | 1262 | /* FIXME: session might not exist yet. create an uninhabited session and wait for a client */ |
1263 | struct ConsensusSession *session; | 1263 | struct ConsensusSession *session; |
1264 | int idx; | ||
1264 | 1265 | ||
1265 | session = sessions_head; | 1266 | for (session = sessions_head; NULL != session; session = session->next) |
1266 | while (NULL != session) | ||
1267 | { | 1267 | { |
1268 | if (0 == GNUNET_CRYPTO_hash_cmp (&session->global_id, &hello->global_id)) | 1268 | if (0 != GNUNET_CRYPTO_hash_cmp (&session->global_id, &hello->global_id)) |
1269 | { | 1269 | continue; |
1270 | int idx; | 1270 | idx = get_peer_idx (&inc->peer_id, session); |
1271 | idx = get_peer_idx (&inc->peer_id, session); | 1271 | GNUNET_assert (-1 != idx); |
1272 | GNUNET_assert (-1 != idx); | 1272 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "peer %d hello'ed session %d\n", idx); |
1273 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "peer %d hello'ed session %d\n", idx); | 1273 | inc->cpi = &session->info[idx]; |
1274 | inc->cpi = &session->info[idx]; | 1274 | inc->cpi->mst = inc->mst; |
1275 | inc->cpi->mst = inc->mst; | 1275 | inc->cpi->hello = GNUNET_YES; |
1276 | inc->cpi->hello = GNUNET_YES; | 1276 | inc->cpi->socket = inc->socket; |
1277 | inc->cpi->socket = inc->socket; | 1277 | embrace_peer (inc->cpi); |
1278 | embrace_peer (inc->cpi); | 1278 | return GNUNET_YES; |
1279 | return GNUNET_YES; | ||
1280 | } | ||
1281 | session = session->next; | ||
1282 | } | 1279 | } |
1283 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "peer tried to HELLO uninhabited session\n"); | 1280 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "peer tried to HELLO uninhabited session\n"); |
1284 | return GNUNET_NO; | 1281 | return GNUNET_NO; |
@@ -1382,7 +1379,7 @@ decode (struct ConsensusPeerInformation *cpi) | |||
1382 | 1379 | ||
1383 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "P%d: decoding ibf from P%d\n", cpi->session->local_peer_idx, (int) (cpi - cpi->session->info)); | 1380 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "P%d: decoding ibf from P%d\n", cpi->session->local_peer_idx, (int) (cpi - cpi->session->info)); |
1384 | 1381 | ||
1385 | for (;;) | 1382 | while (1) |
1386 | { | 1383 | { |
1387 | int res; | 1384 | int res; |
1388 | 1385 | ||
@@ -2574,7 +2571,7 @@ client_conclude (void *cls, | |||
2574 | * @param client client handle | 2571 | * @param client client handle |
2575 | * @param message message sent by the client | 2572 | * @param message message sent by the client |
2576 | */ | 2573 | */ |
2577 | void | 2574 | static void |
2578 | client_ack (void *cls, | 2575 | client_ack (void *cls, |
2579 | struct GNUNET_SERVER_Client *client, | 2576 | struct GNUNET_SERVER_Client *client, |
2580 | const struct GNUNET_MessageHeader *message) | 2577 | const struct GNUNET_MessageHeader *message) |
diff --git a/src/consensus/ibf.c b/src/consensus/ibf.c index a51137493..2d2949334 100644 --- a/src/consensus/ibf.c +++ b/src/consensus/ibf.c | |||
@@ -280,12 +280,12 @@ ibf_write_slice (const struct InvertibleBloomFilter *ibf, uint32_t start, uint32 | |||
280 | * Read an ibf. | 280 | * Read an ibf. |
281 | * | 281 | * |
282 | * @param buf pointer to the buffer to write to, will point to first | 282 | * @param buf pointer to the buffer to write to, will point to first |
283 | * byte after the written data | 283 | * byte after the written data // FIXME: take 'const void *buf' for input, return number of bytes READ |
284 | * @param size size of the buffer, will be updated | 284 | * @param size size of the buffer, will be updated |
285 | * @param start which bucket to start at | 285 | * @param start which bucket to start at |
286 | * @param count how many buckets to read | 286 | * @param count how many buckets to read |
287 | * @param ibf the ibf to read from | 287 | * @param ibf the ibf to read from |
288 | * @return GNUNET_OK on success | 288 | * @return GNUNET_OK on success // FIXME: return 0 on error (or -1/ssize_t), number of bytes read otherwise |
289 | */ | 289 | */ |
290 | int | 290 | int |
291 | ibf_read_slice (void **buf, size_t *size, uint32_t start, uint32_t count, struct InvertibleBloomFilter *ibf) | 291 | ibf_read_slice (void **buf, size_t *size, uint32_t start, uint32_t count, struct InvertibleBloomFilter *ibf) |