2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file dht/gnunet-service-dht_neighbours.c
23 * @brief GNUnet DHT service's bucket and neighbour management code
24 * @author Christian Grothoff
25 * @author Nathan Evans
29 #include "gnunet_block_lib.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_constants.h"
32 #include "gnunet_protocols.h"
33 #include "gnunet_nse_service.h"
34 #include "gnunet_core_service.h"
35 #include "gnunet_datacache_lib.h"
36 #include "gnunet_transport_service.h"
37 #include "gnunet_hello_lib.h"
38 #include "gnunet_dht_service.h"
39 #include "gnunet_statistics_service.h"
41 #include "gnunet-service-dht.h"
42 #include "gnunet-service-dht_clients.h"
43 #include "gnunet-service-dht_datacache.h"
44 #include "gnunet-service-dht_nse.h"
45 #include "gnunet-service-dht_routing.h"
49 * How many buckets will we allow total.
51 #define MAX_BUCKETS sizeof (GNUNET_HashCode) * 8
54 * What is the maximum number of peers in a given bucket.
56 #define DEFAULT_BUCKET_SIZE 4
59 * Size of the bloom filter the DHT uses to filter peers.
61 #define DHT_BLOOM_SIZE 128
64 * How often to update our preference levels for peers in our routing tables.
66 #define DHT_DEFAULT_PREFERENCE_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2)
69 * How long at least to wait before sending another find peer request.
71 #define DHT_MINIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2)
74 * How long at most to wait before sending another find peer request.
76 #define DHT_MAXIMUM_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 8)
85 * Type: GNUNET_MESSAGE_TYPE_DHT_P2P_PUT
87 struct GNUNET_MessageHeader header;
92 uint32_t options GNUNET_PACKED;
97 uint32_t type GNUNET_PACKED;
102 uint32_t hop_count GNUNET_PACKED;
105 * Replication level for this message
107 uint32_t desired_replication_level GNUNET_PACKED;
110 * Length of the PUT path that follows (if tracked).
112 uint32_t put_path_length GNUNET_PACKED;
115 * When does the content expire?
117 struct GNUNET_TIME_AbsoluteNBO expiration_time;
120 * Bloomfilter (for peer identities) to stop circular routes
122 char bloomfilter[DHT_BLOOM_SIZE];
125 * The key we are storing under.
129 /* put path (if tracked) */
139 struct PeerResultMessage
142 * Type: GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT
144 struct GNUNET_MessageHeader header;
149 uint32_t type GNUNET_PACKED;
152 * Length of the PUT path that follows (if tracked).
154 uint32_t put_path_length GNUNET_PACKED;
157 * Length of the GET path that follows (if tracked).
159 uint32_t get_path_length GNUNET_PACKED;
162 * When does the content expire?
164 struct GNUNET_TIME_AbsoluteNBO expiration_time;
167 * The key of the corresponding GET request.
171 /* put path (if tracked) */
173 /* get path (if tracked) */
183 struct PeerGetMessage
186 * Type: GNUNET_MESSAGE_TYPE_DHT_P2P_GET
188 struct GNUNET_MessageHeader header;
193 uint32_t options GNUNET_PACKED;
196 * Desired content type.
198 uint32_t type GNUNET_PACKED;
203 uint32_t hop_count GNUNET_PACKED;
206 * Desired replication level for this request.
208 uint32_t desired_replication_level GNUNET_PACKED;
211 * Size of the extended query.
213 uint32_t xquery_size;
216 * Bloomfilter mutator.
221 * Bloomfilter (for peer identities) to stop circular routes
223 char bloomfilter[DHT_BLOOM_SIZE];
226 * The key we are looking for.
232 /* result bloomfilter */
238 * Linked list of messages to send to a particular other peer.
240 struct P2PPendingMessage
243 * Pointer to next item in the list
245 struct P2PPendingMessage *next;
248 * Pointer to previous item in the list
250 struct P2PPendingMessage *prev;
253 * Message importance level. FIXME: used? useful?
255 unsigned int importance;
258 * When does this message time out?
260 struct GNUNET_TIME_Absolute timeout;
263 * Actual message to be sent, allocated at the end of the struct:
264 * // msg = (cast) &pm[1];
265 * // memcpy (&pm[1], data, len);
267 const struct GNUNET_MessageHeader *msg;
273 * Entry for a peer in a bucket.
278 * Next peer entry (DLL)
280 struct PeerInfo *next;
283 * Prev peer entry (DLL)
285 struct PeerInfo *prev;
288 * Count of outstanding messages for peer. FIXME: NEEDED?
289 * FIXME: bound queue size!?
291 unsigned int pending_count;
294 * Head of pending messages to be sent to this peer.
296 struct P2PPendingMessage *head;
299 * Tail of pending messages to be sent to this peer.
301 struct P2PPendingMessage *tail;
304 * Core handle for sending messages to this peer.
306 struct GNUNET_CORE_TransmitHandle *th;
309 * Preference update context
311 struct GNUNET_CORE_InformationRequestContext *info_ctx;
314 * Task for scheduling message sends.
316 GNUNET_SCHEDULER_TaskIdentifier send_task;
319 * Task for scheduling preference updates
321 GNUNET_SCHEDULER_TaskIdentifier preference_task;
324 * What is the identity of the peer?
326 struct GNUNET_PeerIdentity id;
330 * What is the average latency for replies received?
332 struct GNUNET_TIME_Relative latency;
335 * Transport level distance to peer.
337 unsigned int distance;
344 * Peers are grouped into buckets.
351 struct PeerInfo *head;
356 struct PeerInfo *tail;
359 * Number of peers in the bucket.
361 unsigned int peers_size;
366 * The lowest currently used bucket, initially 0 (for 0-bits matching bucket).
368 static unsigned int closest_bucket;
371 * How many peers have we added since we sent out our last
374 static unsigned int newly_found_peers;
377 * The buckets. Array of size MAX_BUCKET_SIZE. Offset 0 means 0 bits matching.
379 static struct PeerBucket k_buckets[MAX_BUCKETS];
382 * Hash map of all known peers, for easy removal from k_buckets on disconnect.
384 static struct GNUNET_CONTAINER_MultiHashMap *all_known_peers;
387 * Maximum size for each bucket.
389 static unsigned int bucket_size = DEFAULT_BUCKET_SIZE;
392 * Task that sends FIND PEER requests.
394 static GNUNET_SCHEDULER_TaskIdentifier find_peer_task;
397 * Identity of this peer.
399 static struct GNUNET_PeerIdentity my_identity;
402 * Handle to GNUnet core.
404 static struct GNUNET_CORE_Handle *coreAPI;
408 * Find the optimal bucket for this key.
410 * @param hc the hashcode to compare our identity to
411 * @return the proper bucket index, or GNUNET_SYSERR
412 * on error (same hashcode)
415 find_bucket (const GNUNET_HashCode * hc)
419 bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, hc);
420 if (bits == MAX_BUCKETS)
422 /* How can all bits match? Got my own ID? */
424 return GNUNET_SYSERR;
426 return MAX_BUCKETS - bits - 1;
431 * Let GNUnet core know that we like the given peer.
433 * @param cls the 'struct PeerInfo' of the peer
434 * @param tc scheduler context.
437 update_core_preference (void *cls,
438 const struct GNUNET_SCHEDULER_TaskContext *tc);
442 * Function called with statistics about the given peer.
445 * @param peer identifies the peer
446 * @param bpm_out set to the current bandwidth limit (sending) for this peer
447 * @param amount set to the amount that was actually reserved or unreserved;
448 * either the full requested amount or zero (no partial reservations)
449 * @param res_delay if the reservation could not be satisfied (amount was 0), how
450 * long should the client wait until re-trying?
451 * @param preference current traffic preference for the given peer
454 update_core_preference_finish (void *cls,
455 const struct GNUNET_PeerIdentity *peer,
456 struct GNUNET_BANDWIDTH_Value32NBO bpm_out,
458 struct GNUNET_TIME_Relative res_delay,
461 struct PeerInfo *peer_info = cls;
463 peer_info->info_ctx = NULL;
464 peer_info->preference_task
465 = GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL,
466 &update_core_preference, peer_info);
471 * Let GNUnet core know that we like the given peer.
473 * @param cls the 'struct PeerInfo' of the peer
474 * @param tc scheduler context.
477 update_core_preference (void *cls,
478 const struct GNUNET_SCHEDULER_TaskContext *tc)
480 struct PeerInfo *peer = cls;
482 unsigned int matching;
485 peer->preference_task = GNUNET_SCHEDULER_NO_TASK;
486 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
489 GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey,
490 &peer->id.hashPubKey);
493 bucket = find_bucket(&peer->id.hashPubKey);
494 if (bucket == GNUNET_SYSERR)
497 preference = (1LL << matching) / k_buckets[bucket].peers_size;
500 peer->preference_task
501 = GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL,
502 &update_core_preference, peer);
506 GNUNET_CORE_peer_change_preference (coreAPI, &peer->id,
507 GNUNET_TIME_UNIT_FOREVER_REL,
508 GNUNET_BANDWIDTH_VALUE_MAX, 0,
510 &update_core_preference_finish, peer);
515 * Method called whenever a peer connects.
518 * @param peer peer identity this notification is about
519 * @param atsi performance data
522 handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
523 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
525 struct PeerInfo *ret;
528 /* Check for connect to self message */
529 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
532 GNUNET_CONTAINER_multihashmap_contains (all_known_peers,
538 peer_bucket = find_bucket (&peer->hashPubKey);
539 GNUNET_assert ( (peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS) );
540 ret = GNUNET_malloc (sizeof (struct PeerInfo));
542 ret->latency = latency;
543 ret->distance = distance;
546 GNUNET_CONTAINER_DLL_insert_after (k_buckets[peer_bucket].head,
547 k_buckets[peer_bucket].tail,
548 k_buckets[peer_bucket].tail, ret);
549 k_buckets[peer_bucket].peers_size++;
550 closest_bucket = GNUNET_MAX (closest_bucket,
552 if ( (peer_bucket > 0) &&
553 (k_buckets[peer_bucket].peers_size <= bucket_size) )
554 ret->preference_task = GNUNET_SCHEDULER_add_now (&update_core_preference, ret);
556 GNUNET_assert (GNUNET_OK ==
557 GNUNET_CONTAINER_multihashmap_put (all_known_peers,
558 &peer->hashPubKey, ret,
559 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
564 * Method called whenever a peer disconnects.
567 * @param peer peer identity this notification is about
570 handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
572 struct PeerInfo *to_remove;
574 struct P2PPendingMessage *pos;
576 /* Check for disconnect from self message */
577 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
580 GNUNET_CONTAINER_multihashmap_get (all_known_peers, &peer->hashPubKey);
581 if (NULL == to_remove)
586 GNUNET_assert (GNUNET_YES ==
587 GNUNET_CONTAINER_multihashmap_remove (all_known_peers,
590 if (NULL != to_remove->info_ctx)
592 GNUNET_CORE_peer_change_preference_cancel (to_remove->info_ctx);
593 to_remove->info_ctx = NULL;
595 current_bucket = find_bucket (&to_remove->id.hashPubKey);
596 GNUNET_CONTAINER_DLL_remove (k_buckets[current_bucket].head,
597 k_buckets[current_bucket].tail,
599 GNUNET_assert (k_buckets[current_bucket].peers_size > 0);
600 k_buckets[current_bucket].peers_size--;
601 while ( (closest_bucket > 0) &&
602 (k_buckets[closest_bucket].peers_size == 0) )
605 if (to_remove->th != NULL)
607 GNUNET_CORE_notify_transmit_ready_cancel (to_remove->th);
608 to_remove->th = NULL;
610 while (NULL != (pos = to_remove->head))
612 GNUNET_CONTAINER_DLL_remove (to_remove->head,
621 * Called when core is ready to send a message we asked for
622 * out to the destination.
624 * @param cls the 'struct PeerInfo' of the target peer
625 * @param size number of bytes available in buf
626 * @param buf where the callee should write the message
627 * @return number of bytes written to buf
630 core_transmit_notify (void *cls, size_t size, void *buf)
632 struct PeerInfo *peer = cls;
634 struct P2PPendingMessage *pending;
641 /* client disconnected */
644 if (peer->head == NULL)
646 /* no messages pending */
650 while ( (NULL != (pending = peer->head)) &&
651 (size - off >= (msize = ntohs (pending->msg->size))) )
653 memcpy (&cbuf[off], pending->msg, msize);
655 peer->pending_count--;
656 GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
657 GNUNET_free (pending);
659 if (peer->head != NULL)
661 = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
663 GNUNET_TIME_absolute_get_remaining (pending->timeout),
665 &core_transmit_notify, peer);
672 * Transmit all messages in the peer's message queue.
674 * @param peer message queue to process
677 process_peer_queue (struct PeerInfo *peer)
679 struct P2PPendingMessage *pending;
681 if (NULL != (pending = peer->head))
683 if (NULL != peer->th)
686 = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
688 GNUNET_TIME_absolute_get_remaining (pending->timeout),
690 ntohs (pending->msg->size),
691 &core_transmit_notify, peer);
696 * To how many peers should we (on average) forward the request to
697 * obtain the desired target_replication count (on average).
699 * @param hop_count number of hops the message has traversed
700 * @param target_replication the number of total paths desired
701 * @return Some number of peers to forward the message to
704 get_forward_count (uint32_t hop_count,
705 uint32_t target_replication)
707 uint32_t random_value;
708 uint32_t forward_count;
711 if (hop_count > GDS_NSE_get () * 4.0)
713 /* forcefully terminate */
716 if (hop_count > GDS_NSE_get () * 2.0)
718 /* Once we have reached our ideal number of hops, only forward to 1 peer */
721 /* bound by system-wide maximum */
722 target_replication = GNUNET_MIN (16 /* FIXME: use named constant */,
725 1 + (target_replication - 1.0) / (GDS_NSE_get () +
726 ((float) (target_replication - 1.0) *
728 /* Set forward count to floor of target_value */
729 forward_count = (uint32_t) target_value;
730 /* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */
731 target_value = target_value - forward_count;
733 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX);
734 if (random_value < (target_value * UINT32_MAX))
736 return forward_count;
741 * Compute the distance between have and target as a 32-bit value.
742 * Differences in the lower bits must count stronger than differences
743 * in the higher bits.
745 * @return 0 if have==target, otherwise a number
746 * that is larger as the distance between
747 * the two hash codes increases
750 distance (const GNUNET_HashCode * target, const GNUNET_HashCode * have)
757 /* We have to represent the distance between two 2^9 (=512)-bit
758 * numbers as a 2^5 (=32)-bit number with "0" being used for the
759 * two numbers being identical; furthermore, we need to
760 * guarantee that a difference in the number of matching
761 * bits is always represented in the result.
763 * We use 2^32/2^9 numerical values to distinguish between
764 * hash codes that have the same LSB bit distance and
765 * use the highest 2^9 bits of the result to signify the
766 * number of (mis)matching LSB bits; if we have 0 matching
767 * and hence 512 mismatching LSB bits we return -1 (since
768 * 512 itself cannot be represented with 9 bits) */
770 /* first, calculate the most significant 9 bits of our
771 * result, aka the number of LSBs */
772 bucket = GNUNET_CRYPTO_hash_matching_bits (target, have);
773 /* bucket is now a value between 0 and 512 */
775 return 0; /* perfect match */
777 return (unsigned int) -1; /* LSB differs; use max (if we did the bit-shifting
778 * below, we'd end up with max+1 (overflow)) */
780 /* calculate the most significant bits of the final result */
781 msb = (512 - bucket) << (32 - 9);
782 /* calculate the 32-9 least significant bits of the final result by
783 * looking at the differences in the 32-9 bits following the
784 * mismatching bit at 'bucket' */
787 (i < sizeof (GNUNET_HashCode) * 8) && (i < bucket + 1 + 32 - 9); i++)
789 if (GNUNET_CRYPTO_hash_get_bit (target, i) !=
790 GNUNET_CRYPTO_hash_get_bit (have, i))
791 lsb |= (1 << (bucket + 32 - 9 - i)); /* first bit set will be 10,
792 * last bit set will be 31 -- if
793 * i does not reach 512 first... */
800 * Return a number that is larger the closer the
801 * "have" GNUNET_hash code is to the "target".
803 * @return inverse distance metric, non-zero.
804 * Must fudge the value if NO bits match.
807 inverse_distance (const GNUNET_HashCode * target, const GNUNET_HashCode * have)
809 if (GNUNET_CRYPTO_hash_matching_bits (target, have) == 0)
810 return 1; /* Never return 0! */
811 return ((unsigned int) -1) - distance (target, have);
816 * Check whether my identity is closer than any known peers. If a
817 * non-null bloomfilter is given, check if this is the closest peer
818 * that hasn't already been routed to.
821 * @param key hash code to check closeness to
822 * @param bloom bloomfilter, exclude these entries from the decision
823 * @return GNUNET_YES if node location is closest,
824 * GNUNET_NO otherwise.
828 am_closest_peer (const GNUNET_HashCode *key,
829 const struct GNUNET_CONTAINER_BloomFilter *bloom)
835 struct PeerInfo *pos;
836 unsigned int my_distance;
838 if (0 == memcmp (&my_identity.hashPubKey, key, sizeof (GNUNET_HashCode)))
840 bucket_num = find_bucket (key);
841 bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, key);
842 my_distance = distance (&my_identity.hashPubKey, key);
843 pos = k_buckets[bucket_num].head;
845 while ((pos != NULL) && (count < bucket_size))
847 if ((bloom != NULL) &&
849 GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)))
852 continue; /* Skip already checked entries */
854 other_bits = GNUNET_CRYPTO_hash_matching_bits (&pos->id.hashPubKey, key);
855 if (other_bits > bits)
857 if (other_bits == bits) /* We match the same number of bits */
861 /* No peers closer, we are the closest! */
867 * Select a peer from the routing table that would be a good routing
868 * destination for sending a message for "key". The resulting peer
869 * must not be in the set of blocked peers.<p>
871 * Note that we should not ALWAYS select the closest peer to the
872 * target, peers further away from the target should be chosen with
873 * exponentially declining probability.
875 * FIXME: double-check that this is fine
878 * @param key the key we are selecting a peer to route to
879 * @param bloom a bloomfilter containing entries this request has seen already
880 * @param hops how many hops has this message traversed thus far
881 * @return Peer to route to, or NULL on error
883 static struct PeerInfo *
884 select_peer (const GNUNET_HashCode *key,
885 const struct GNUNET_CONTAINER_BloomFilter *bloom,
890 unsigned int selected;
891 struct PeerInfo *pos;
892 unsigned int distance;
893 unsigned int largest_distance;
894 struct PeerInfo *chosen;
896 if (hops >= GDS_NSE_get ())
898 /* greedy selection (closest peer that is not in bloomfilter) */
899 largest_distance = 0;
901 for (bc = closest_bucket; bc < MAX_BUCKETS; bc++)
903 pos = k_buckets[bc].head;
905 while ((pos != NULL) && (count < bucket_size))
907 /* If we are doing strict Kademlia routing, then checking the bloomfilter is basically cheating! */
909 GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))
911 distance = inverse_distance (key, &pos->id.hashPubKey);
912 if (distance > largest_distance)
915 largest_distance = distance;
925 /* select "random" peer */
926 /* count number of peers that are available and not filtered */
928 for (bc = closest_bucket; bc < MAX_BUCKETS; bc++)
930 pos = k_buckets[bc].head;
931 while ((pos != NULL) && (count < bucket_size))
934 GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))
937 continue; /* Ignore bloomfiltered peers */
943 if (count == 0) /* No peers to select from! */
947 /* Now actually choose a peer */
948 selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, count);
950 for (bc = closest_bucket; bc < MAX_BUCKETS; bc++)
952 pos = k_buckets[bc].head;
953 while ((pos != NULL) && (count < bucket_size))
956 GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))
959 continue; /* Ignore bloomfiltered peers */
972 * Compute the set of peers that the given request should be
975 * @param key routing key
976 * @param bloom bloom filter excluding peers as targets, all selected
977 * peers will be added to the bloom filter
978 * @param hop_count number of hops the request has traversed so far
979 * @param target_replication desired number of replicas
980 * @param targets where to store an array of target peers (to be
981 * free'd by the caller)
982 * @return number of peers returned in 'targets'.
985 get_target_peers (const GNUNET_HashCode *key,
986 struct GNUNET_CONTAINER_BloomFilter *bloom,
988 uint32_t target_replication,
989 struct PeerInfo ***targets)
993 struct PeerInfo **rtargets;
994 struct PeerInfo *nxt;
996 ret = get_forward_count (hop_count, target_replication);
1002 rtargets = GNUNET_malloc (sizeof (struct PeerInfo*) * ret);
1006 nxt = select_peer (key, bloom, hop_count);
1009 rtargets[off++] = nxt;
1010 GNUNET_CONTAINER_bloomfilter_add (bloom, &nxt->id.hashPubKey);
1014 GNUNET_free (rtargets);
1018 *targets = rtargets;
1024 * Perform a PUT operation. Forwards the given request to other
1025 * peers. Does not store the data locally. Does not give the
1026 * data to local clients. May do nothing if this is the only
1027 * peer in the network (or if we are the closest peer in the
1030 * @param type type of the block
1031 * @param options routing options
1032 * @param desired_replication_level desired replication count
1033 * @param expiration_time when does the content expire
1034 * @param hop_count how many hops has this message traversed so far
1035 * @param bf Bloom filter of peers this PUT has already traversed
1036 * @param key key for the content
1037 * @param put_path_length number of entries in put_path
1038 * @param put_path peers this request has traversed so far (if tracked)
1039 * @param data payload to store
1040 * @param data_size number of bytes in data
1043 GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
1044 enum GNUNET_DHT_RouteOption options,
1045 uint32_t desired_replication_level,
1046 struct GNUNET_TIME_Absolute expiration_time,
1048 struct GNUNET_CONTAINER_BloomFilter *bf,
1049 const GNUNET_HashCode *key,
1050 unsigned int put_path_length,
1051 struct GNUNET_PeerIdentity *put_path,
1055 unsigned int target_count;
1057 struct PeerInfo **targets;
1058 struct PeerInfo *target;
1059 struct P2PPendingMessage *pending;
1061 struct PeerPutMessage *ppm;
1062 struct GNUNET_PeerIdentity *pp;
1064 target_count = get_target_peers (key, bf, hop_count,
1065 desired_replication_level,
1067 if (0 == target_count)
1069 msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage);
1070 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
1072 put_path_length = 0;
1073 msize = data_size + sizeof (struct PeerPutMessage);
1075 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
1080 for (i=0;i<target_count;i++)
1082 target = targets[i];
1083 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1084 pending->importance = 0; /* FIXME */
1085 pending->timeout = expiration_time;
1086 ppm = (struct PeerPutMessage*) &pending[1];
1087 pending->msg = &ppm->header;
1088 ppm->header.size = htons (msize);
1089 ppm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_PUT);
1090 ppm->options = htonl (options);
1091 ppm->type = htonl (type);
1092 ppm->hop_count = htonl (hop_count + 1);
1093 ppm->desired_replication_level = htonl (desired_replication_level);
1094 ppm->put_path_length = htonl (put_path_length);
1095 ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
1096 GNUNET_assert (GNUNET_OK ==
1097 GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
1101 pp = (struct GNUNET_PeerIdentity*) &ppm[1];
1102 memcpy (pp, put_path, sizeof (struct GNUNET_PeerIdentity) * put_path_length);
1103 memcpy (&pp[put_path_length], data, data_size);
1104 GNUNET_CONTAINER_DLL_insert (target->head,
1107 target->pending_count++;
1108 process_peer_queue (target);
1110 GNUNET_free (targets);
1115 * Perform a GET operation. Forwards the given request to other
1116 * peers. Does not lookup the key locally. May do nothing if this is
1117 * the only peer in the network (or if we are the closest peer in the
1120 * @param type type of the block
1121 * @param options routing options
1122 * @param desired_replication_level desired replication count
1123 * @param hop_count how many hops did this request traverse so far?
1124 * @param key key for the content
1125 * @param xquery extended query
1126 * @param xquery_size number of bytes in xquery
1127 * @param reply_bf bloomfilter to filter duplicates
1128 * @param reply_bf_mutator mutator for reply_bf
1129 * @param peer_bf filter for peers not to select (again)
1132 GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
1133 enum GNUNET_DHT_RouteOption options,
1134 uint32_t desired_replication_level,
1136 const GNUNET_HashCode *key,
1139 const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
1140 uint32_t reply_bf_mutator,
1141 struct GNUNET_CONTAINER_BloomFilter *peer_bf)
1143 unsigned int target_count;
1145 struct PeerInfo **targets;
1146 struct PeerInfo *target;
1147 struct P2PPendingMessage *pending;
1149 struct PeerGetMessage *pgm;
1151 size_t reply_bf_size;
1153 target_count = get_target_peers (key, peer_bf, hop_count,
1154 desired_replication_level,
1156 if (0 == target_count)
1158 reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf);
1159 msize = xquery_size + sizeof (struct PeerGetMessage) + reply_bf_size;
1160 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
1165 /* forward request */
1166 for (i=0;i<target_count;i++)
1168 target = targets[i];
1169 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1170 pending->importance = 0; /* FIXME */
1171 pending->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS); /* FIXME */
1172 pgm = (struct PeerGetMessage*) &pending[1];
1173 pending->msg = &pgm->header;
1174 pgm->header.size = htons (msize);
1175 pgm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_GET);
1176 pgm->options = htonl (options);
1177 pgm->type = htonl (type);
1178 pgm->hop_count = htonl (hop_count + 1);
1179 pgm->desired_replication_level = htonl (desired_replication_level);
1180 pgm->xquery_size = htonl (xquery_size);
1181 pgm->bf_mutator = reply_bf_mutator;
1182 GNUNET_assert (GNUNET_OK ==
1183 GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf,
1187 xq = (char *) &pgm[1];
1188 memcpy (xq, xquery, xquery_size);
1189 GNUNET_assert (GNUNET_OK ==
1190 GNUNET_CONTAINER_bloomfilter_get_raw_data (reply_bf,
1193 GNUNET_CONTAINER_DLL_insert (target->head,
1196 target->pending_count++;
1197 process_peer_queue (target);
1199 GNUNET_free (targets);
1204 * Handle a reply (route to origin). Only forwards the reply back to
1205 * the given peer. Does not do local caching or forwarding to local
1208 * @param target neighbour that should receive the block (if still connected)
1209 * @param type type of the block
1210 * @param expiration_time when does the content expire
1211 * @param key key for the content
1212 * @param put_path_length number of entries in put_path
1213 * @param put_path peers the original PUT traversed (if tracked)
1214 * @param get_path_length number of entries in put_path
1215 * @param get_path peers this reply has traversed so far (if tracked)
1216 * @param data payload of the reply
1217 * @param data_size number of bytes in data
1220 GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target,
1221 enum GNUNET_BLOCK_Type type,
1222 struct GNUNET_TIME_Absolute expiration_time,
1223 const GNUNET_HashCode *key,
1224 unsigned int put_path_length,
1225 struct GNUNET_PeerIdentity *put_path,
1226 unsigned int get_path_length,
1227 struct GNUNET_PeerIdentity *get_path,
1231 struct PeerInfo *pi;
1232 struct P2PPendingMessage *pending;
1234 struct PeerResultMessage *prm;
1235 struct GNUNET_PeerIdentity *paths;
1237 msize = data_size + sizeof (struct PeerResultMessage) +
1238 (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
1239 if ( (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
1240 (get_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
1241 (put_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
1242 (data_size > GNUNET_SERVER_MAX_MESSAGE_SIZE) )
1247 pi = GNUNET_CONTAINER_multihashmap_get (all_known_peers,
1248 &target->hashPubKey);
1251 /* peer disconnected in the meantime, drop reply */
1254 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1255 pending->importance = 0; /* FIXME */
1256 pending->timeout = expiration_time;
1257 prm = (struct PeerResultMessage*) &pending[1];
1258 pending->msg = &prm->header;
1259 prm->header.size = htons (msize);
1260 prm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT);
1261 prm->type = htonl (type);
1262 prm->put_path_length = htonl (put_path_length);
1263 prm->get_path_length = htonl (get_path_length);
1264 prm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
1266 paths = (struct GNUNET_PeerIdentity*) &prm[1];
1267 memcpy (paths, put_path, put_path_length * sizeof (struct GNUNET_PeerIdentity));
1268 memcpy (&paths[put_path_length],
1269 get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity));
1270 memcpy (&paths[put_path_length + get_path_length],
1272 GNUNET_CONTAINER_DLL_insert (pi->head,
1275 pi->pending_count++;
1276 process_peer_queue (pi);
1281 * Closure for 'add_known_to_bloom'.
1283 struct BloomConstructorContext
1286 * Bloom filter under construction.
1288 struct GNUNET_CONTAINER_BloomFilter *bloom;
1293 uint32_t bf_mutator;
1298 * Add each of the peers we already know to the bloom filter of
1299 * the request so that we don't get duplicate HELLOs.
1301 * @param cls the 'struct BloomConstructorContext'.
1302 * @param key peer identity to add to the bloom filter
1303 * @param value value the peer information (unused)
1304 * @return GNUNET_YES (we should continue to iterate)
1307 add_known_to_bloom (void *cls, const GNUNET_HashCode * key, void *value)
1309 struct BloomConstructorContext *ctx = cls;
1312 GNUNET_BLOCK_mingle_hash (key, ctx->bf_mutator, &mh);
1313 GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh);
1319 * Task to send a find peer message for our own peer identifier
1320 * so that we can find the closest peers in the network to ourselves
1321 * and attempt to connect to them.
1323 * @param cls closure for this task
1324 * @param tc the context under which the task is running
1327 send_find_peer_message (void *cls,
1328 const struct GNUNET_SCHEDULER_TaskContext *tc)
1330 struct GNUNET_TIME_Relative next_send_time;
1331 struct BloomConstructorContext bcc;
1333 find_peer_task = GNUNET_SCHEDULER_NO_TASK;
1334 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
1336 if (newly_found_peers > bucket_size)
1338 /* If we are finding many peers already, no need to send out our request right now! */
1339 find_peer_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
1340 &send_find_peer_message, NULL);
1341 newly_found_peers = 0;
1344 bcc.bf_mutator = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
1346 GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K);
1347 GNUNET_CONTAINER_multihashmap_iterate (all_known_peers,
1348 &add_known_to_bloom,
1350 // FIXME: pass priority!?
1351 GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO,
1352 GNUNET_DHT_RO_FIND_PEER,
1353 16 /* FIXME: replication level? */,
1355 &my_identity.hashPubKey,
1357 bcc.bloom, bcc.bf_mutator, NULL);
1358 GNUNET_CONTAINER_bloomfilter_free (bcc.bloom);
1359 /* schedule next round */
1360 newly_found_peers = 0;
1361 next_send_time.rel_value =
1362 (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) +
1363 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG,
1364 DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2);
1365 find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time,
1366 &send_find_peer_message,
1372 * To be called on core init/fail.
1374 * @param cls service closure
1375 * @param server handle to the server for this service
1376 * @param identity the public identity of this peer
1377 * @param publicKey the public key of this peer
1380 core_init (void *cls, struct GNUNET_CORE_Handle *server,
1381 const struct GNUNET_PeerIdentity *identity,
1382 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
1384 struct GNUNET_TIME_Relative next_send_time;
1386 GNUNET_assert (server != NULL);
1387 my_identity = *identity;
1388 /* FIXME: do upon 1st connect instead! */
1389 next_send_time.rel_value =
1390 DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value +
1391 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG,
1392 (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value /
1394 DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value);
1395 find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time,
1396 &send_find_peer_message,
1402 * Core handler for p2p put requests.
1404 * @param cls closure
1405 * @param peer sender of the request
1406 * @param message message
1407 * @param peer peer identity this notification is about
1408 * @param atsi performance data
1409 * @return GNUNET_OK to keep the connection open,
1410 * GNUNET_SYSERR to close it (signal serious error)
1413 handle_dht_p2p_put (void *cls,
1414 const struct GNUNET_PeerIdentity *peer,
1415 const struct GNUNET_MessageHeader *message,
1416 const struct GNUNET_TRANSPORT_ATS_Information
1419 const struct PeerPutMessage *put;
1420 const struct GNUNET_PeerIdentity *put_path;
1421 const void *payload;
1424 size_t payload_size;
1425 struct GNUNET_CONTAINER_BloomFilter *bf;
1426 GNUNET_HashCode test_key;
1428 msize = ntohs (message->size);
1429 if (msize < sizeof (struct PeerPutMessage))
1431 GNUNET_break_op (0);
1434 put = (const struct PeerPutMessage*) message;
1435 putlen = ntohl (put->put_path_length);
1436 if ( (msize < sizeof (struct PeerPutMessage) + putlen * sizeof (struct GNUNET_PeerIdentity)) ||
1437 (putlen > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) )
1439 GNUNET_break_op (0);
1442 put_path = (const struct GNUNET_PeerIdentity*) &put[1];
1443 payload = &put_path[putlen];
1444 payload_size = msize - (sizeof (struct PeerPutMessage) +
1445 putlen * sizeof (struct GNUNET_PeerIdentity));
1446 switch (GNUNET_BLOCK_get_key (GDS_block_context,
1448 payload, payload_size,
1452 if (0 != memcmp (&test_key, &put->key, sizeof (GNUNET_HashCode)))
1454 GNUNET_break_op (0);
1459 GNUNET_break_op (0);
1462 /* cannot verify, good luck */
1465 bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter,
1469 struct GNUNET_PeerIdentity pp[putlen+1];
1471 /* extend 'put path' by sender */
1472 memcpy (pp, put_path, putlen * sizeof (struct GNUNET_PeerIdentity));
1475 /* give to local clients */
1476 GDS_CLIENT_handle_reply (GNUNET_TIME_absolute_ntoh (put->expiration_time),
1485 GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time),
1491 /* route to other peers */
1492 GDS_NEIGHBOURS_handle_put (ntohl (put->type),
1493 ntohl (put->options),
1494 ntohl (put->desired_replication_level),
1495 GNUNET_TIME_absolute_ntoh (put->expiration_time),
1496 ntohl (put->hop_count) + 1 /* who adds +1? */,
1503 GNUNET_CONTAINER_bloomfilter_free (bf);
1509 * Core handler for p2p get requests.
1511 * @param cls closure
1512 * @param peer sender of the request
1513 * @param message message
1514 * @param peer peer identity this notification is about
1515 * @param atsi performance data
1516 * @return GNUNET_OK to keep the connection open,
1517 * GNUNET_SYSERR to close it (signal serious error)
1520 handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
1521 const struct GNUNET_MessageHeader *message,
1522 const struct GNUNET_TRANSPORT_ATS_Information
1525 struct PeerGetMessage *get;
1526 uint32_t xquery_size;
1527 size_t reply_bf_size;
1529 enum GNUNET_BLOCK_Type type;
1530 enum GNUNET_DHT_RouteOption options;
1531 enum GNUNET_BLOCK_EvaluationResult eval;
1532 struct GNUNET_CONTAINER_BloomFilter *reply_bf;
1533 struct GNUNET_CONTAINER_BloomFilter *peer_bf;
1536 /* parse and validate message */
1537 msize = ntohs (message->size);
1538 if (msize < sizeof (struct PeerGetMessage))
1540 GNUNET_break_op (0);
1543 get = (struct PeerGetMessage *) message;
1544 xquery_size = ntohl (get->xquery_size);
1545 if (msize < sizeof (struct PeerGetMessage) + xquery_size)
1547 GNUNET_break_op (0);
1550 reply_bf_size = msize - (sizeof (struct PeerGetMessage) + xquery_size);
1551 type = ntohl (get->type);
1552 options = ntohl (get->options);
1553 xquery = (const char*) &get[1];
1555 if (reply_bf_size > 0)
1556 reply_bf = GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size],
1558 GNUNET_DHT_GET_BLOOMFILTER_K);
1559 eval = GNUNET_BLOCK_evaluate (GDS_block_context,
1564 xquery, xquery_size,
1566 if (eval != GNUNET_BLOCK_EVALUATION_REQUEST_VALID)
1568 /* request invalid or block type not supported */
1569 GNUNET_break_op (eval == GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED);
1570 if (NULL != reply_bf)
1571 GNUNET_CONTAINER_bloomfilter_free (reply_bf);
1575 GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter,
1579 /* remember request for routing replies */
1580 GDS_ROUTING_add (peer,
1583 xquery, xquery_size,
1584 reply_bf, get->bf_mutator);
1585 /* FIXME: check options (find peer, local-processing-only-if-nearest, etc.!) */
1587 /* local lookup (this may update the reply_bf) */
1588 GDS_DATACACHE_handle_get (&get->key,
1590 xquery, xquery_size,
1593 /* FIXME: should track if the local lookup resulted in a
1594 definitive result and then NOT do P2P forwarding */
1596 /* P2P forwarding */
1597 GDS_NEIGHBOURS_handle_get (type,
1599 ntohl (get->desired_replication_level),
1600 ntohl (get->hop_count) + 1, /* CHECK: where (else) do we do +1? */
1602 xquery, xquery_size,
1607 if (NULL != reply_bf)
1608 GNUNET_CONTAINER_bloomfilter_free (reply_bf);
1609 GNUNET_CONTAINER_bloomfilter_free (peer_bf);
1615 * Core handler for p2p result messages.
1617 * @param cls closure
1618 * @param message message
1619 * @param peer peer identity this notification is about
1620 * @param atsi performance data
1621 * @return GNUNET_YES (do not cut p2p connection)
1624 handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
1625 const struct GNUNET_MessageHeader *message,
1626 const struct GNUNET_TRANSPORT_ATS_Information
1629 const struct PeerResultMessage *prm;
1630 const struct GNUNET_PeerIdentity *put_path;
1631 const struct GNUNET_PeerIdentity *get_path;
1633 uint32_t get_path_length;
1634 uint32_t put_path_length;
1637 enum GNUNET_BLOCK_Type type;
1639 /* parse and validate message */
1640 msize = ntohs (message->size);
1641 if (msize < sizeof (struct PeerResultMessage))
1643 GNUNET_break_op (0);
1646 prm = (struct PeerResultMessage *) message;
1647 put_path_length = ntohl (prm->put_path_length);
1648 get_path_length = ntohl (prm->get_path_length);
1649 if ( (msize < sizeof (struct PeerResultMessage) +
1650 (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity)) ||
1651 (get_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
1652 (put_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) )
1654 GNUNET_break_op (0);
1657 put_path = (const struct GNUNET_PeerIdentity*) &prm[1];
1658 get_path = &put_path[put_path_length];
1659 type = ntohl (prm->type);
1660 data = (const void*) &get_path[get_path_length];
1661 data_size = msize - (sizeof (struct PeerResultMessage) +
1662 (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity));
1663 /* append 'peer' to 'get_path' */
1665 struct GNUNET_PeerIdentity xget_path[get_path_length+1];
1667 memcpy (xget_path, get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity));
1668 xget_path[get_path_length] = *peer;
1670 /* forward to local clients */
1671 GDS_CLIENT_handle_reply (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
1673 get_path_length + 1,
1681 /* forward to other peers */
1682 GDS_ROUTING_process (type,
1683 GNUNET_TIME_absolute_ntoh (prm->expiration_time),
1687 get_path_length + 1,
1697 * Initialize neighbours subsystem.
1699 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1702 GDS_NEIGHBOURS_init ()
1704 static struct GNUNET_CORE_MessageHandler core_handlers[] = {
1705 {&handle_dht_p2p_get, GNUNET_MESSAGE_TYPE_DHT_P2P_GET, 0},
1706 {&handle_dht_p2p_put, GNUNET_MESSAGE_TYPE_DHT_P2P_PUT, 0},
1707 {&handle_dht_p2p_result, GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT, 0},
1710 unsigned long long temp_config_num;
1713 GNUNET_CONFIGURATION_get_value_number (GDS_cfg, "DHT", "bucket_size",
1715 bucket_size = (unsigned int) temp_config_num;
1716 coreAPI = GNUNET_CORE_connect (GDS_cfg,
1720 &handle_core_connect,
1721 &handle_core_disconnect,
1722 NULL, /* Do we care about "status" updates? */
1726 if (coreAPI == NULL)
1727 return GNUNET_SYSERR;
1728 all_known_peers = GNUNET_CONTAINER_multihashmap_create (256);
1730 struct GNUNET_TIME_Relative next_send_time;
1733 next_send_time.rel_value =
1734 DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value +
1735 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG,
1736 (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value /
1738 DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value);
1739 find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time,
1740 &send_find_peer_message,
1741 &find_peer_context);
1748 * Shutdown neighbours subsystem.
1751 GDS_NEIGHBOURS_done ()
1753 if (coreAPI == NULL)
1755 GNUNET_CORE_disconnect (coreAPI);
1757 GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (all_known_peers));
1758 GNUNET_CONTAINER_multihashmap_destroy (all_known_peers);
1759 all_known_peers = NULL;
1760 if (GNUNET_SCHEDULER_NO_TASK != find_peer_task)
1762 GNUNET_SCHEDULER_cancel (find_peer_task);
1763 find_peer_task = GNUNET_SCHEDULER_NO_TASK;
1768 /* end of gnunet-service-dht_neighbours.c */