diff options
author | Julius Bünger <buenger@mytum.de> | 2014-12-24 15:11:41 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2014-12-24 15:11:41 +0000 |
commit | 0d2f7894d7ba9d3cfa1cb577c9ab6e00b3d9e9c7 (patch) | |
tree | 6d0fb7bb42f591b067f7e4a394aac7367664dd9e /src | |
parent | 23fa03199548424901516bfea8f9568ef492833a (diff) | |
download | gnunet-0d2f7894d7ba9d3cfa1cb577c9ab6e00b3d9e9c7.tar.gz gnunet-0d2f7894d7ba9d3cfa1cb577c9ab6e00b3d9e9c7.zip |
now using API calls instead of own fkts
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index e09db5ca6..0c3fb792d 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -218,31 +218,6 @@ SAMPLER_init(struct GNUNET_PeerIdentity *id) | |||
218 | } | 218 | } |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * Compare two hashes. | ||
222 | * | ||
223 | * Used by SAMPLER_next() to compare hashes. | ||
224 | */ | ||
225 | int | ||
226 | hash_cmp(struct GNUNET_HashCode *hash1, struct GNUNET_HashCode *hash2) | ||
227 | { | ||
228 | return memcmp( (const void *) hash1, (const void *) hash2, sizeof(struct GNUNET_HashCode)); | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Compare two PeerIDs. | ||
233 | * | ||
234 | * Used by SAMPLER_next() to compare hashes. | ||
235 | * @param p1 Some peer identity. | ||
236 | * @param p2 Some peer identity. | ||
237 | * @return 1 if p1 > p2, -1 if p1 < p2 and 0 if p1 == p2. | ||
238 | */ | ||
239 | int | ||
240 | peer_cmp(const struct GNUNET_PeerIdentity *id1, const struct GNUNET_PeerIdentity *id2) | ||
241 | { | ||
242 | return memcmp( (const void *) id1, (const void *) id2, sizeof(struct GNUNET_PeerIdentity)); | ||
243 | } | ||
244 | |||
245 | /** | ||
246 | * Input an PeerID into the given sampler. | 221 | * Input an PeerID into the given sampler. |
247 | */ | 222 | */ |
248 | static void | 223 | static void |
@@ -258,7 +233,7 @@ SAMPLER_next(struct Sampler *s, const struct GNUNET_PeerIdentity *other, | |||
258 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Old PeerID %s at %p\n", | 233 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Old PeerID %s at %p\n", |
259 | GNUNET_i2s(s->peer_id), s->peer_id); | 234 | GNUNET_i2s(s->peer_id), s->peer_id); |
260 | 235 | ||
261 | if ( 0 == peer_cmp(other, s->peer_id) ) | 236 | if ( 0 == GNUNET_CRYPTO_cmp_peer_identity(other, s->peer_id) ) |
262 | { | 237 | { |
263 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s\n", | 238 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s\n", |
264 | GNUNET_i2s(other)); | 239 | GNUNET_i2s(other)); |
@@ -285,7 +260,7 @@ SAMPLER_next(struct Sampler *s, const struct GNUNET_PeerIdentity *other, | |||
285 | insertCB(insertCLS, s->peer_id, s->peer_id_hash); | 260 | insertCB(insertCLS, s->peer_id, s->peer_id_hash); |
286 | } | 261 | } |
287 | } | 262 | } |
288 | else if ( 0 > hash_cmp(&other_hash, &s->peer_id_hash) ) | 263 | else if ( 0 > GNUNET_CRYPTO_hash_cmp(&other_hash, &s->peer_id_hash) ) |
289 | { | 264 | { |
290 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s\n", | 265 | LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s\n", |
291 | GNUNET_i2s(other)); | 266 | GNUNET_i2s(other)); |
@@ -538,7 +513,7 @@ SAMPLER_count_id ( struct Samplers *samplers, const struct GNUNET_PeerIdentity * | |||
538 | count = 0; | 513 | count = 0; |
539 | while ( NULL != iter ) | 514 | while ( NULL != iter ) |
540 | { | 515 | { |
541 | if ( 0 == peer_cmp( iter->peer_id, id) ) | 516 | if ( 0 == GNUNET_CRYPTO_cmp_peer_identity( iter->peer_id, id) ) |
542 | count++; | 517 | count++; |
543 | iter = iter->next; | 518 | iter = iter->next; |
544 | } | 519 | } |
@@ -894,7 +869,7 @@ nse_callback(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimat | |||
894 | 869 | ||
895 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Received a ns estimate - logest: %f, std_dev: %f\n", logestimate, std_dev); | 870 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Received a ns estimate - logest: %f, std_dev: %f\n", logestimate, std_dev); |
896 | //scale = .01; | 871 | //scale = .01; |
897 | estimate = 1 << (uint64_t) round(logestimate); | 872 | estimate = GNUNET_NSE_log_estimate_to_n(logestimate); |
898 | // GNUNET_NSE_log_estimate_to_n (logestimate); | 873 | // GNUNET_NSE_log_estimate_to_n (logestimate); |
899 | estimate = pow(estimate, 1./3);// * (std_dev * scale); // TODO add | 874 | estimate = pow(estimate, 1./3);// * (std_dev * scale); // TODO add |
900 | if ( 0 < estimate ) { | 875 | if ( 0 < estimate ) { |