count = 0;
while ((pos != NULL) && (count < bucket_size))
{
- if ((bloom == NULL) ||
- (GNUNET_NO ==
- GNUNET_CONTAINER_bloomfilter_test (bloom,
- &pos->phash)))
+ if ( (NULL == bloom) ||
+ (GNUNET_NO ==
+ GNUNET_CONTAINER_bloomfilter_test (bloom,
+ &pos->phash)))
{
dist = get_distance (key,
&pos->phash);
}
if (NULL == chosen)
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peer selection failed"), 1,
+ gettext_noop ("# Peer selection failed"),
+ 1,
GNUNET_NO);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Selected peer `%s' in greedy routing for %s\n",
+ GNUNET_i2s (chosen->id),
+ GNUNET_h2s (key));
return chosen;
}
for (bc = 0; bc <= closest_bucket; bc++)
{
pos = k_buckets[bc].head;
- while ((pos != NULL) && (count < bucket_size))
+ while ( (NULL != pos) && (count < bucket_size) )
{
- if ((bloom != NULL) &&
- (GNUNET_YES ==
- GNUNET_CONTAINER_bloomfilter_test (bloom,
- &pos->phash)))
+ if ( (NULL != bloom) &&
+ (GNUNET_YES ==
+ GNUNET_CONTAINER_bloomfilter_test (bloom,
+ &pos->phash)) )
{
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop
continue; /* Ignore bloomfiltered peers */
}
if (0 == selected--)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Selected peer `%s' in random routing for %s\n",
+ GNUNET_i2s (pos->id),
+ GNUNET_h2s (key));
return pos;
+ }
}
}
GNUNET_break (0);
struct PeerInfo *);
for (off = 0; off < ret; off++)
{
- nxt = select_peer (key, bloom, hop_count);
+ nxt = select_peer (key,
+ bloom,
+ hop_count);
if (NULL == nxt)
break;
rtargets[off] = nxt;
"Adding myself (%s) to PUT bloomfilter for %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (key));
- GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity_hash);
+ GNUNET_CONTAINER_bloomfilter_add (bf,
+ &my_identity_hash);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# PUT requests routed"),
1,
/**
* Handle a result from local datacache for a GET operation.
*
- * @param cls the `struct ClientHandle` of the client doing the query
+ * @param cls the `struct PeerInfo` for which this is a reply
* @param type type of the block
* @param expiration_time when does the content expire
* @param key key for the content
const void *data,
size_t data_size)
{
+ struct PeerInfo *peer = cls;
char *pp;
pp = GNUNET_STRINGS_pp2s (put_path,
GNUNET_h2s (key),
pp);
GNUNET_free (pp);
- // FIXME: we can probably do better here by
- // passing the peer that did the query in the closure...
- GDS_ROUTING_process (NULL,
- type,
- expiration_time,
- key,
- put_path_length, put_path,
- 0, NULL,
- data, data_size);
+ GDS_NEIGHBOURS_handle_reply (peer->id,
+ type,
+ expiration_time,
+ key,
+ put_path_length, put_path,
+ get_path_length, get_path,
+ data, data_size);
}
const char *xquery;
int forwarded;
- if (NULL == peer)
- {
- GNUNET_break (0);
- return;
- }
/* parse and validate message */
msize = ntohs (get->header.size);
xquery_size = ntohl (get->xquery_size);
"filter-size",
reply_bf_size,
NULL);
- /* remember request for routing replies */
- GDS_ROUTING_add (peer->id,
- type,
- bg, /* bg now owned by routing, but valid at least until end of this function! */
- options,
- &get->key,
- xquery,
- xquery_size);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GET for %s at %s after %u hops\n",
GNUNET_h2s (&get->key),
xquery_size,
bg,
&handle_local_result,
- NULL);
+ peer);
}
}
else
GNUNET_NO);
}
+ /* remember request for routing replies */
+ GDS_ROUTING_add (peer->id,
+ type,
+ bg, /* bg now owned by routing, but valid at least until end of this function! */
+ options,
+ &get->key,
+ xquery,
+ xquery_size);
+
/* P2P forwarding */
forwarded = GNUNET_NO;
if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)