2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 2011, 2015 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_datacache.h
23 * @brief GNUnet DHT service's datacache integration
24 * @author Christian Grothoff
25 * @author Nathan Evans
27 #ifndef GNUNET_SERVICE_DHT_DATACACHE_H
28 #define GNUNET_SERVICE_DHT_DATACACHE_H
30 #include "gnunet_util_lib.h"
31 #include "gnunet_block_lib.h"
34 * Handle a datum we've received from another peer. Cache if
37 * @param expiration when will the reply expire
38 * @param key the query this reply is for
39 * @param put_path_length number of peers in @a put_path
40 * @param put_path path the reply took on put
41 * @param get_path_length number of peers in @a get_path
42 * @param get_path path the reply took on get
43 * @param type type of the reply
44 * @param data_size number of bytes in @a data
45 * @param data application payload data
48 GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
49 const struct GNUNET_HashCode *key,
50 unsigned int put_path_length,
51 const struct GNUNET_PeerIdentity *put_path,
52 unsigned int get_path_length,
53 const struct GNUNET_PeerIdentity *get_path,
54 enum GNUNET_BLOCK_Type type,
60 * Handle a GET request we've received from another peer.
62 * @param trail_id trail where the reply needs to be send to
63 * @param key the query
64 * @param type requested data type
65 * @param xquery extended query
66 * @param xquery_size number of bytes in @a xquery
67 * @param reply_bf where the reply bf is (to be) stored, possibly updated!, can be NULL
68 * @param reply_bf_mutator mutation value for @a reply_bf
69 * @return evaluation result for the local replies
71 enum GNUNET_BLOCK_EvaluationResult
72 GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *trail_id,
73 const struct GNUNET_HashCode *key,
74 enum GNUNET_BLOCK_Type type,
77 struct GNUNET_CONTAINER_BloomFilter **reply_bf,
78 uint32_t reply_bf_mutator);
82 * Obtain a random key from the datacache.
83 * Used by Whanau for load-balancing.
85 * @param[out] key where to store the key of a random element,
86 * randomized by PRNG if datacache is empty
87 * @return #GNUNET_OK on success, #GNUNET_SYSERR if the datacache is empty
90 GDS_DATACACHE_get_random_key (struct GNUNET_HashCode *key);
94 * Handle a request for data close to a key that we have received from
97 * @param trail_id trail where the reply needs to be send to
98 * @param key the location at which the peer is looking for data that is close
101 GDS_DATACACHE_get_successors (const struct GNUNET_HashCode *trail_id,
102 const struct GNUNET_HashCode *key);
106 * Initialize datacache subsystem.
109 GDS_DATACACHE_init (void);
113 * Shutdown datacache subsystem.
116 GDS_DATACACHE_done (void);