#include "gnunet_hello_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_statistics_service.h"
-#include "dht.h"
#include "gnunet-service-dht.h"
#include "gnunet-service-dht_clients.h"
#include "gnunet-service-dht_datacache.h"
#include "gnunet-service-dht_nse.h"
#include "gnunet-service-dht_routing.h"
#include <fenv.h>
+#include "dht.h"
/**
* How many buckets will we allow total.
/**
* What is the maximum number of peers in a given bucket.
*/
-#define DEFAULT_BUCKET_SIZE 4
-
-/**
- * Size of the bloom filter the DHT uses to filter peers.
- */
-#define DHT_BLOOM_SIZE 128
+#define DEFAULT_BUCKET_SIZE 8
/**
* Desired replication level for FIND PEER requests
/**
* How long at least to wait before sending another find peer request.
*/
-#define DHT_MINIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2)
+#define DHT_MINIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
/**
* How long at most to wait before sending another find peer request.
*/
-#define DHT_MAXIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 8)
+#define DHT_MAXIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 10)
/**
* How long at most to wait for transmission of a GET request to another peer?
static struct GNUNET_CORE_Handle *coreAPI;
+
/**
* Find the optimal bucket for this key.
*
&peer->id.hashPubKey);
if (matching >= 64)
matching = 63;
- bucket = find_bucket(&peer->id.hashPubKey);
+ bucket = find_bucket (&peer->id.hashPubKey);
if (bucket == GNUNET_SYSERR)
preference = 0;
else
+ {
+ GNUNET_assert (k_buckets[bucket].peers_size != 0);
preference = (1LL << matching) / k_buckets[bucket].peers_size;
+ }
if (preference == 0)
{
peer->preference_task
GNUNET_HashCode mh;
GNUNET_BLOCK_mingle_hash (key, ctx->bf_mutator, &mh);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n",
+ GNUNET_h2s (key),
+ ctx->bf_mutator);
GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh);
return GNUNET_YES;
}
{
struct GNUNET_TIME_Relative next_send_time;
struct BloomConstructorContext bcc;
+ struct GNUNET_CONTAINER_BloomFilter *peer_bf;
find_peer_task = GNUNET_SCHEDULER_NO_TASK;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
}
bcc.bf_mutator = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
bcc.bloom =
- GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K);
+ GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, GNUNET_CONSTANTS_BLOOMFILTER_K);
GNUNET_CONTAINER_multihashmap_iterate (all_known_peers,
&add_known_to_bloom,
&bcc);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# FIND PEER messages initiated"), 1,
GNUNET_NO);
+ peer_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
+ DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
// FIXME: pass priority!?
GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO,
GNUNET_DHT_RO_FIND_PEER,
0,
&my_identity.hashPubKey,
NULL, 0,
- bcc.bloom, bcc.bf_mutator, NULL);
+ bcc.bloom, bcc.bf_mutator,
+ peer_bf);
+ GNUNET_CONTAINER_bloomfilter_free (peer_bf);
GNUNET_CONTAINER_bloomfilter_free (bcc.bloom);
/* schedule next round */
- newly_found_peers = 0;
next_send_time.rel_value =
- (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) +
- GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG,
- DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2);
+ DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value +
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / (newly_found_peers+1));
+ newly_found_peers = 0;
find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time,
&send_find_peer_message,
NULL);
/* Check for connect to self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connected %s to %s\n",
+ GNUNET_i2s (&my_identity),
+ GNUNET_h2s (&peer->hashPubKey));
if (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains (all_known_peers,
&peer->hashPubKey))
peer_bucket);
if ( (peer_bucket > 0) &&
(k_buckets[peer_bucket].peers_size <= bucket_size) )
+ {
ret->preference_task = GNUNET_SCHEDULER_add_now (&update_core_preference, ret);
- newly_found_peers++;
+ newly_found_peers++;
+ }
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (all_known_peers,
&peer->hashPubKey, ret,
struct PeerInfo *to_remove;
int current_bucket;
struct P2PPendingMessage *pos;
+ unsigned int discarded;
/* Check for disconnect from self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnected %s from %s\n",
+ GNUNET_i2s (&my_identity),
+ GNUNET_h2s (&peer->hashPubKey));
to_remove =
GNUNET_CONTAINER_multihashmap_get (all_known_peers, &peer->hashPubKey);
if (NULL == to_remove)
GNUNET_CORE_peer_change_preference_cancel (to_remove->info_ctx);
to_remove->info_ctx = NULL;
}
+ if (GNUNET_SCHEDULER_NO_TASK != to_remove->preference_task)
+ {
+ GNUNET_SCHEDULER_cancel (to_remove->preference_task);
+ to_remove->preference_task = GNUNET_SCHEDULER_NO_TASK;
+ }
current_bucket = find_bucket (&to_remove->id.hashPubKey);
GNUNET_CONTAINER_DLL_remove (k_buckets[current_bucket].head,
k_buckets[current_bucket].tail,
GNUNET_CORE_notify_transmit_ready_cancel (to_remove->th);
to_remove->th = NULL;
}
+ discarded = 0;
while (NULL != (pos = to_remove->head))
{
GNUNET_CONTAINER_DLL_remove (to_remove->head,
to_remove->tail,
pos);
+ discarded++;
GNUNET_free (pos);
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Queued messages discarded (peer disconnected)"), discarded,
+ GNUNET_NO);
+ GNUNET_free (to_remove);
}
size_t msize;
peer->th = NULL;
- if (buf == NULL)
+ while ( (NULL != (pending = peer->head)) &&
+ (GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value == 0) )
{
- /* client disconnected */
- return 0;
+ peer->pending_count--;
+ GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
+ GNUNET_free (pending);
}
- if (peer->head == NULL)
+ if (pending == NULL)
{
/* no messages pending */
return 0;
}
+ if (buf == NULL)
+ {
+ peer->th
+ = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining (pending->timeout),
+ &peer->id, ntohs (pending->msg->size),
+ &core_transmit_notify, peer);
+ GNUNET_break (NULL != peer->th);
+ return 0;
+ }
off = 0;
while ( (NULL != (pending = peer->head)) &&
(size - off >= (msize = ntohs (pending->msg->size))) )
GNUNET_free (pending);
}
if (peer->head != NULL)
+ {
peer->th
= GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
- pending->importance,
- GNUNET_TIME_absolute_get_remaining (pending->timeout),
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining (pending->timeout),
&peer->id, msize,
- &core_transmit_notify, peer);
+ &core_transmit_notify, peer);
+ GNUNET_break (NULL != peer->th);
+ }
return off;
}
{
struct P2PPendingMessage *pending;
- if (NULL != (pending = peer->head))
+ if (NULL == (pending = peer->head))
return;
if (NULL != peer->th)
return;
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Bytes of bandwdith requested from core"),
+ ntohs (pending->msg->size),
+ GNUNET_NO);
peer->th
= GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
pending->importance,
&peer->id,
ntohs (pending->msg->size),
&core_transmit_notify, peer);
+ GNUNET_break (NULL != peer->th);
}
uint32_t forward_count;
float target_value;
- if (hop_count > GDS_NSE_get () * 4.0)
+ if (hop_count > GDS_NSE_get () * 6.0)
{
/* forcefully terminate */
return 0;
}
- if (hop_count > GDS_NSE_get () * 2.0)
+ if (hop_count > GDS_NSE_get () * 4.0)
{
/* Once we have reached our ideal number of hops, only forward to 1 peer */
return 1;
/* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */
target_value = target_value - forward_count;
random_value =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
if (random_value < (target_value * UINT32_MAX))
forward_count++;
return forward_count;
/* greedy selection (closest peer that is not in bloomfilter) */
smallest_distance = UINT_MAX;
chosen = NULL;
- for (bc = closest_bucket; bc < MAX_BUCKETS; bc++)
+ for (bc = 0; bc < closest_bucket; bc++)
{
pos = k_buckets[bc].head;
count = 0;
while ((pos != NULL) && (count < bucket_size))
{
- if (GNUNET_NO ==
- GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))
- {
+ if ( (bloom == NULL) ||
+ (GNUNET_NO ==
+ GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)) )
+ {
dist = get_distance (key, &pos->id.hashPubKey);
if (dist < smallest_distance)
{
smallest_distance = dist;
}
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Excluded peer `%s' due to BF match in greedy routing for %s\n",
+ GNUNET_i2s (&pos->id),
+ GNUNET_h2s (key));
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
+ GNUNET_NO);
+ }
count++;
pos = pos->next;
}
}
+ if (NULL == chosen)
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Peer selection failed"), 1,
+ GNUNET_NO);
return chosen;
}
pos = k_buckets[bc].head;
while ((pos != NULL) && (count < bucket_size))
{
- if (GNUNET_YES ==
- GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))
+ if ( (bloom != NULL) &&
+ (GNUNET_YES ==
+ GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)) )
{
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
+ GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Excluded peer `%s' due to BF match in random routing for %s\n",
+ GNUNET_i2s (&pos->id),
+ GNUNET_h2s (key));
pos = pos->next;
continue; /* Ignore bloomfiltered peers */
}
}
if (count == 0) /* No peers to select from! */
{
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Peer selection failed"), 1,
+ GNUNET_NO);
return NULL;
}
/* Now actually choose a peer */
pos = k_buckets[bc].head;
while ((pos != NULL) && (count < bucket_size))
{
- if (GNUNET_YES ==
- GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))
+ if ( (bloom != NULL) &&
+ (GNUNET_YES ==
+ GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)) )
{
pos = pos->next;
continue; /* Ignore bloomfiltered peers */
struct PeerInfo **rtargets;
struct PeerInfo *nxt;
+ GNUNET_assert (NULL != bloom);
ret = get_forward_count (hop_count, target_replication);
if (ret == 0)
{
return 0;
}
rtargets = GNUNET_malloc (sizeof (struct PeerInfo*) * ret);
- off = 0;
- while (ret-- > 0)
+ for (off = 0; off < ret; off++)
{
nxt = select_peer (key, bloom, hop_count);
if (nxt == NULL)
- break;
- rtargets[off++] = nxt;
- GNUNET_CONTAINER_bloomfilter_add (bloom, &nxt->id.hashPubKey);
+ break;
+ rtargets[off] = nxt;
+ GNUNET_break (GNUNET_NO ==
+ GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey));
+ GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[off]->id.hashPubKey);
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Selected %u/%u peers at hop %u for %s (target was %u)\n",
+ off,
+ GNUNET_CONTAINER_multihashmap_size (all_known_peers),
+ (unsigned int) hop_count,
+ GNUNET_h2s (key),
+ ret);
if (0 == off)
{
GNUNET_free (rtargets);
struct PeerPutMessage *ppm;
struct GNUNET_PeerIdentity *pp;
+ GNUNET_assert (NULL != bf);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding myself (%s) to PUT bloomfilter for %s\n",
+ GNUNET_i2s (&my_identity),
+ GNUNET_h2s (key));
+ GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity.hashPubKey);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# PUT requests routed"), 1,
GNUNET_NO);
desired_replication_level,
&targets);
if (0 == target_count)
- return;
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Routing PUT for %s terminates after %u hops at %s\n",
+ GNUNET_h2s (key),
+ (unsigned int) hop_count,
+ GNUNET_i2s (&my_identity));
+ return;
+ }
msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage);
if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peers selected as targets for PUT requests"), target_count,
+ gettext_noop ("# PUT messages queued for transmission"), target_count,
GNUNET_NO);
for (i=0;i<target_count;i++)
{
target = targets[i];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Routing PUT for %s after %u hops to %s\n",
+ GNUNET_h2s (key),
+ (unsigned int) hop_count,
+ GNUNET_i2s (&target->id));
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
pending->timeout = expiration_time;
ppm->desired_replication_level = htonl (desired_replication_level);
ppm->put_path_length = htonl (put_path_length);
ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
+ GNUNET_break (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &target->id.hashPubKey));
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
ppm->bloomfilter,
struct PeerGetMessage *pgm;
char *xq;
size_t reply_bf_size;
-
+
+ GNUNET_assert (NULL != peer_bf);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# GET requests routed"), 1,
GNUNET_NO);
target_count = get_target_peers (key, peer_bf, hop_count,
desired_replication_level,
&targets);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding myself (%s) to GET bloomfilter for %s\n",
+ GNUNET_i2s (&my_identity),
+ GNUNET_h2s (key));
+ GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
if (0 == target_count)
- return;
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Routing GET for %s terminates after %u hops at %s\n",
+ GNUNET_h2s (key),
+ (unsigned int) hop_count,
+ GNUNET_i2s (&my_identity));
+ return;
+ }
reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf);
msize = xquery_size + sizeof (struct PeerGetMessage) + reply_bf_size;
if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peers selected as targets for GET requests"), target_count,
+ gettext_noop ("# GET messages queued for transmission"), target_count,
GNUNET_NO);
/* forward request */
for (i=0;i<target_count;i++)
{
target = targets[i];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Routing GET for %s after %u hops to %s\n",
+ GNUNET_h2s (key),
+ (unsigned int) hop_count,
+ GNUNET_i2s (&target->id));
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
pgm->desired_replication_level = htonl (desired_replication_level);
pgm->xquery_size = htonl (xquery_size);
pgm->bf_mutator = reply_bf_mutator;
+ GNUNET_break (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (peer_bf, &target->id.hashPubKey));
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf,
pgm->bloomfilter,
pgm->key = *key;
xq = (char *) &pgm[1];
memcpy (xq, xquery, xquery_size);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_bloomfilter_get_raw_data (reply_bf,
- &xq[xquery_size],
- reply_bf_size));
+ if (NULL != reply_bf)
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_bloomfilter_get_raw_data (reply_bf,
+ &xq[xquery_size],
+ reply_bf_size));
GNUNET_CONTAINER_DLL_insert_tail (target->head,
target->tail,
pending);
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# REPLIES routed"), 1,
+ gettext_noop ("# RESULT messages queued for transmission"), 1,
GNUNET_NO);
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
/* cannot verify, good luck */
break;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "PUT for %s at %s\n",
+ GNUNET_h2s (&put->key),
+ GNUNET_i2s (&my_identity));
bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter,
DHT_BLOOM_SIZE,
- DHT_BLOOM_K);
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GNUNET_break_op (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &peer->hashPubKey));
{
struct GNUNET_PeerIdentity pp[putlen+1];
options,
ntohl (put->desired_replication_level),
GNUNET_TIME_absolute_ntoh (put->expiration_time),
- ntohl (put->hop_count) + 1 /* who adds +1? */,
+ ntohl (put->hop_count),
bf,
&put->key,
putlen, pp,
if (NULL != GDS_my_hello)
{
GNUNET_BLOCK_mingle_hash (&my_identity.hashPubKey, bf_mutator, &mhash);
- if (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (bf, &mhash))
-
+ if ( (NULL == bf) ||
+ (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (bf, &mhash)) )
+ {
GDS_NEIGHBOURS_handle_reply (sender,
GNUNET_BLOCK_TYPE_DHT_HELLO,
GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION),
0, NULL,
GDS_my_hello,
GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message*) GDS_my_hello));
+ }
+ else
+ {
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# FIND PEER requests ignored due to Bloomfilter"), 1,
+ GNUNET_NO);
+ }
+ }
+ else
+ {
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# FIND PEER requests ignored due to lack of HELLO"), 1,
+ GNUNET_NO);
}
/* then, also consider sending a random HELLO from the closest bucket */
- bucket_idx = find_bucket (key);
+ if (0 == memcmp (&my_identity.hashPubKey, key, sizeof (GNUNET_HashCode)))
+ bucket_idx = closest_bucket;
+ else
+ bucket_idx = GNUNET_MIN (closest_bucket, find_bucket (key));
if (bucket_idx == GNUNET_SYSERR)
return;
bucket = &k_buckets[bucket_idx];
if (bucket->peers_size == 0)
return;
- choice = GNUNET_CRYPTO_random_u32 (bucket->peers_size,
- GNUNET_CRYPTO_QUALITY_WEAK);
+ choice = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ bucket->peers_size);
peer = bucket->head;
while (choice > 0)
{
GNUNET_assert (peer != NULL);
peer = peer->next;
+ choice--;
}
choice = bucket->peers_size;
do
struct GNUNET_CONTAINER_BloomFilter *reply_bf;
struct GNUNET_CONTAINER_BloomFilter *peer_bf;
const char *xquery;
-
+
+ GNUNET_break (0 != memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)));
/* parse and validate message */
msize = ntohs (message->size);
if (msize < sizeof (struct PeerGetMessage))
if (reply_bf_size > 0)
reply_bf = GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size],
reply_bf_size,
- GNUNET_DHT_GET_BLOOMFILTER_K);
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
eval = GNUNET_BLOCK_evaluate (GDS_block_context,
type,
&get->key,
peer_bf =
GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter,
DHT_BLOOM_SIZE,
- DHT_BLOOM_K);
-
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GNUNET_break_op (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (peer_bf, &peer->hashPubKey));
/* remember request for routing replies */
GDS_ROUTING_add (peer,
type,
&get->key,
xquery, xquery_size,
reply_bf, get->bf_mutator);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "GET for %s at %s after %u hops\n",
+ GNUNET_h2s (&get->key),
+ GNUNET_i2s (&my_identity),
+ (unsigned int) ntohl (get->hop_count));
/* local lookup (this may update the reply_bf) */
if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
(am_closest_peer (&get->key,
peer_bf) ) )
- {
+ {
if ( (0 != (options & GNUNET_DHT_RO_FIND_PEER)))
{
GNUNET_STATISTICS_update (GDS_stats,
get->bf_mutator);
}
}
+ else
+ {
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# P2P GET requests ONLY routed"), 1,
+ GNUNET_NO);
+ }
/* P2P forwarding */
if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
GDS_NEIGHBOURS_handle_get (type,
options,
ntohl (get->desired_replication_level),
- ntohl (get->hop_count) + 1, /* CHECK: where (else) do we do +1? */
+ ntohl (get->hop_count),
&get->key,
xquery, xquery_size,
reply_bf,
GNUNET_break_op (0);
return GNUNET_YES;
}
- bucket = find_bucket (&pid.hashPubKey);
- if ( (bucket >= 0) &&
- (k_buckets[bucket].peers_size < bucket_size) )
- {
- if (NULL != GDS_transport_handle)
- GNUNET_TRANSPORT_offer_hello (GDS_transport_handle,
- h, NULL, NULL);
- (void) GNUNET_CORE_peer_request_connect (coreAPI,
- &pid,
- NULL, NULL);
- }
+ if (0 != memcmp (&my_identity, &pid, sizeof (struct GNUNET_PeerIdentity)))
+ {
+ bucket = find_bucket (&pid.hashPubKey);
+ if ( (bucket >= 0) &&
+ (k_buckets[bucket].peers_size < bucket_size) )
+ {
+ if (NULL != GDS_transport_handle)
+ GNUNET_TRANSPORT_offer_hello (GDS_transport_handle,
+ h, NULL, NULL);
+ (void) GNUNET_CORE_peer_request_connect (coreAPI,
+ &pid,
+ NULL, NULL);
+ }
+ }
}
/* append 'peer' to 'get_path' */