convert fs publish to MQ
[oweals/gnunet.git] / src / dht / gnunet-service-wdht_datacache.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009, 2010, 2011, 2015 GNUnet e.V.
4
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.
9
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.
14
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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file dht/gnunet-service-dht_datacache.h
23  * @brief GNUnet DHT service's datacache integration
24  * @author Christian Grothoff
25  * @author Nathan Evans
26  */
27 #ifndef GNUNET_SERVICE_DHT_DATACACHE_H
28 #define GNUNET_SERVICE_DHT_DATACACHE_H
29
30 #include "gnunet_util_lib.h"
31 #include "gnunet_block_lib.h"
32 #include "gnunet_dht_service.h"
33
34 /**
35  * Handle a datum we've received from another peer.  Cache if
36  * possible.
37  *
38  * @param expiration when will the reply expire
39  * @param key the query this reply is for
40  * @param put_path_length number of peers in @a put_path
41  * @param put_path path the reply took on put
42  * @param get_path_length number of peers in @a get_path
43  * @param get_path path the reply took on get
44  * @param type type of the reply
45  * @param data_size number of bytes in @a data
46  * @param data application payload data
47  */
48 void
49 GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
50                           const struct GNUNET_HashCode *key,
51                           unsigned int put_path_length,
52                           const struct GNUNET_PeerIdentity *put_path,
53                           unsigned int get_path_length,
54                           const struct GNUNET_PeerIdentity *get_path,
55                           enum GNUNET_BLOCK_Type type,
56                           size_t data_size,
57                           const void *data);
58
59
60 /**
61  * Handle a GET request we've received from another peer.
62  *
63  * @param trail_id trail where the reply needs to be send to
64  * @param options routing options (to be passed along)
65  * @param key the query
66  * @param type requested data type
67  * @param xquery extended query
68  * @param xquery_size number of bytes in @a xquery
69  * @param reply_bf where the reply bf is (to be) stored, possibly updated!, can be NULL
70  * @param reply_bf_mutator mutation value for @a reply_bf
71  * @return evaluation result for the local replies
72  *
73  * FIXME: also pass options, so we know to record paths or not...
74  */
75 enum GNUNET_BLOCK_EvaluationResult
76 GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *trail_id,
77                           enum GNUNET_DHT_RouteOption options,
78                           const struct GNUNET_HashCode *key,
79                           enum GNUNET_BLOCK_Type type,
80                           const void *xquery,
81                           size_t xquery_size,
82                           struct GNUNET_CONTAINER_BloomFilter **reply_bf,
83                           uint32_t reply_bf_mutator);
84
85
86 /**
87  * Obtain a random key from the datacache.
88  * Used by Whanau for load-balancing.
89  *
90  * @param[out] key where to store the key of a random element,
91  *             randomized by PRNG if datacache is empty
92  * @return #GNUNET_OK on success, #GNUNET_SYSERR if the datacache is empty
93  */
94 int
95 GDS_DATACACHE_get_random_key (struct GNUNET_HashCode *key);
96
97
98 /**
99  * Handle a request for data close to a key that we have received from
100  * another peer.
101  *
102  * @param trail_id trail where the reply needs to be send to
103  * @param key the location at which the peer is looking for data that is close
104  */
105 void
106 GDS_DATACACHE_get_successors (const struct GNUNET_HashCode *trail_id,
107                               const struct GNUNET_HashCode *key);
108
109
110 /**
111  * Initialize datacache subsystem.
112  */
113 void
114 GDS_DATACACHE_init (void);
115
116
117 /**
118  * Shutdown datacache subsystem.
119  */
120 void
121 GDS_DATACACHE_done (void);
122
123 #endif