GNUNET_HashCode mh;
GNUNET_BLOCK_mingle_hash (key, ctx->bf_mutator, &mh);
-#if DEBUG_DHT
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);
-#endif
GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh);
return GNUNET_YES;
}
/* Check for connect to self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
-#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected %s to %s\n",
GNUNET_i2s (&my_identity), GNUNET_h2s (&peer->hashPubKey));
-#endif
if (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains (all_known_peers,
&peer->hashPubKey))
/* Check for disconnect from self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
-#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnected %s from %s\n",
GNUNET_i2s (&my_identity), GNUNET_h2s (&peer->hashPubKey));
-#endif
to_remove =
GNUNET_CONTAINER_multihashmap_get (all_known_peers, &peer->hashPubKey);
if (NULL == to_remove)
}
else
{
-#if DEBUG_DHT
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));
-#endif
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop
("# Peers excluded from routing due to Bloomfilter"),
gettext_noop
("# Peers excluded from routing due to Bloomfilter"),
1, GNUNET_NO);
-#if DEBUG_DHT
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));
-#endif
pos = pos->next;
continue; /* Ignore bloomfiltered peers */
}
&nxt->id.hashPubKey));
GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[off]->id.hashPubKey);
}
-#if DEBUG_DHT
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);
-#endif
if (0 == off)
{
GNUNET_free (rtargets);
struct GNUNET_PeerIdentity *pp;
GNUNET_assert (NULL != bf);
-#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding myself (%s) to PUT bloomfilter for %s\n",
GNUNET_i2s (&my_identity), GNUNET_h2s (key));
-#endif
GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity.hashPubKey);
GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# PUT requests routed"),
1, GNUNET_NO);
&targets);
if (0 == target_count)
{
-#if DEBUG_DHT
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));
-#endif
return;
}
msize =
for (i = 0; i < target_count; i++)
{
target = targets[i];
-#if DEBUG_DHT
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));
-#endif
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
pending->timeout = expiration_time;
target_count =
get_target_peers (key, peer_bf, hop_count, desired_replication_level,
&targets);
-#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding myself (%s) to GET bloomfilter for %s\n",
GNUNET_i2s (&my_identity), GNUNET_h2s (key));
-#endif
GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
if (0 == target_count)
{
-#if DEBUG_DHT
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));
-#endif
return;
}
reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf);
for (i = 0; i < target_count; i++)
{
target = targets[i];
-#if DEBUG_DHT
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));
-#endif
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
/* cannot verify, good luck */
break;
}
-#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for %s at %s\n",
GNUNET_h2s (&put->key), GNUNET_i2s (&my_identity));
-#endif
bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, DHT_BLOOM_SIZE,
GNUNET_CONSTANTS_BLOOMFILTER_K);
GNUNET_break_op (GNUNET_YES ==
/* remember request for routing replies */
GDS_ROUTING_add (peer, type, options, &get->key, xquery, xquery_size,
reply_bf, get->bf_mutator);
-#if DEBUG_DHT
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));
-#endif
/* local lookup (this may update the reply_bf) */
if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
(am_closest_peer (&get->key, peer_bf)))