diff options
Diffstat (limited to 'src/include/gnunet_datacache_plugin.h')
-rw-r--r-- | src/include/gnunet_datacache_plugin.h | 81 |
1 files changed, 36 insertions, 45 deletions
diff --git a/src/include/gnunet_datacache_plugin.h b/src/include/gnunet_datacache_plugin.h index d7fa8fde0..e144e155e 100644 --- a/src/include/gnunet_datacache_plugin.h +++ b/src/include/gnunet_datacache_plugin.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2006, 2009, 2015 GNUnet e.V. | 3 | Copyright (C) 2006, 2009, 2015, 2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,6 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup dht_libs DHT and support libraries | ||
23 | * @{ | ||
24 | * | ||
22 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
23 | * | 26 | * |
24 | * @file | 27 | * @file |
@@ -31,6 +34,7 @@ | |||
31 | #ifndef PLUGIN_DATACACHE_H | 34 | #ifndef PLUGIN_DATACACHE_H |
32 | #define PLUGIN_DATACACHE_H | 35 | #define PLUGIN_DATACACHE_H |
33 | 36 | ||
37 | |||
34 | #include "gnunet_datacache_lib.h" | 38 | #include "gnunet_datacache_lib.h" |
35 | 39 | ||
36 | #ifdef __cplusplus | 40 | #ifdef __cplusplus |
@@ -105,25 +109,15 @@ struct GNUNET_DATACACHE_PluginFunctions | |||
105 | * Store an item in the datastore. | 109 | * Store an item in the datastore. |
106 | * | 110 | * |
107 | * @param cls closure (internal context for the plugin) | 111 | * @param cls closure (internal context for the plugin) |
108 | * @param key key to store the value under | ||
109 | * @param xor_distance how close is @a key to our PID? | 112 | * @param xor_distance how close is @a key to our PID? |
110 | * @param size number of bytes in @a data | 113 | * @param block data to store |
111 | * @param data data to store | ||
112 | * @param type type of the value | ||
113 | * @param discard_time when to discard the value in any case | ||
114 | * @param path_info_len number of entries in @a path_info | ||
115 | * @param path_info a path through the network | ||
116 | * @return 0 if duplicate, -1 on error, number of bytes used otherwise | 114 | * @return 0 if duplicate, -1 on error, number of bytes used otherwise |
117 | */ | 115 | */ |
118 | ssize_t (*put) (void *cls, | 116 | ssize_t |
119 | const struct GNUNET_HashCode *key, | 117 | (*put) (void *cls, |
120 | uint32_t xor_distance, | 118 | uint32_t xor_distance, |
121 | size_t size, | 119 | const struct GNUNET_DATACACHE_Block *block); |
122 | const char *data, | 120 | |
123 | enum GNUNET_BLOCK_Type type, | ||
124 | struct GNUNET_TIME_Absolute discard_time, | ||
125 | unsigned int path_info_len, | ||
126 | const struct GNUNET_PeerIdentity *path_info); | ||
127 | 121 | ||
128 | /** | 122 | /** |
129 | * Iterate over the results for a particular key | 123 | * Iterate over the results for a particular key |
@@ -136,11 +130,13 @@ struct GNUNET_DATACACHE_PluginFunctions | |||
136 | * @param iter_cls closure for @a iter | 130 | * @param iter_cls closure for @a iter |
137 | * @return the number of results found | 131 | * @return the number of results found |
138 | */ | 132 | */ |
139 | unsigned int (*get) (void *cls, | 133 | unsigned int |
140 | const struct GNUNET_HashCode *key, | 134 | (*get) (void *cls, |
141 | enum GNUNET_BLOCK_Type type, | 135 | const struct GNUNET_HashCode *key, |
142 | GNUNET_DATACACHE_Iterator iter, | 136 | enum GNUNET_BLOCK_Type type, |
143 | void *iter_cls); | 137 | GNUNET_DATACACHE_Iterator iter, |
138 | void *iter_cls); | ||
139 | |||
144 | 140 | ||
145 | /** | 141 | /** |
146 | * Delete the entry with the lowest expiration value | 142 | * Delete the entry with the lowest expiration value |
@@ -149,39 +145,32 @@ struct GNUNET_DATACACHE_PluginFunctions | |||
149 | * @param cls closure (internal context for the plugin) | 145 | * @param cls closure (internal context for the plugin) |
150 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 146 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
151 | */ | 147 | */ |
152 | int (*del) (void *cls); | 148 | enum GNUNET_GenericReturnValue |
153 | 149 | (*del)(void *cls); | |
154 | /** | ||
155 | * Return a random value from the datastore. | ||
156 | * | ||
157 | * @param cls closure (internal context for the plugin) | ||
158 | * @param iter maybe NULL (to just count) | ||
159 | * @param iter_cls closure for @a iter | ||
160 | * @return the number of results found (zero or one) | ||
161 | */ | ||
162 | unsigned int (*get_random) (void *cls, | ||
163 | GNUNET_DATACACHE_Iterator iter, | ||
164 | void *iter_cls); | ||
165 | 150 | ||
166 | 151 | ||
167 | /** | 152 | /** |
168 | * Iterate over the results that are "close" to a particular key in | 153 | * Iterate over the results that are "close" to a particular key in the |
169 | * the datacache. "close" is defined as numerically larger than @a | 154 | * datacache. "close" is defined as returning the @a num_results that are |
170 | * key (when interpreted as a circular address space), with small | 155 | * numerically closest and larger than @a key and also @a num_results that |
171 | * distance. | 156 | * are numerically lower than @a key. Thus, the maximum number of results |
157 | * returned is actually twice @a num_results. | ||
172 | * | 158 | * |
173 | * @param cls closure (internal context for the plugin) | 159 | * @param cls closure (internal context for the plugin) |
174 | * @param key area of the keyspace to look into | 160 | * @param key area of the keyspace to look into |
175 | * @param num_results number of results that should be returned to @a iter | 161 | * @param type desired block type for the replies |
162 | * @param num_results half the number of results that should be returned to @a iter | ||
176 | * @param iter maybe NULL (to just count) | 163 | * @param iter maybe NULL (to just count) |
177 | * @param iter_cls closure for @a iter | 164 | * @param iter_cls closure for @a iter |
178 | * @return the number of results found | 165 | * @return the number of results found |
179 | */ | 166 | */ |
180 | unsigned int (*get_closest) (void *cls, | 167 | unsigned int |
181 | const struct GNUNET_HashCode *key, | 168 | (*get_closest) (void *cls, |
182 | unsigned int num_results, | 169 | const struct GNUNET_HashCode *key, |
183 | GNUNET_DATACACHE_Iterator iter, | 170 | enum GNUNET_BLOCK_Type type, |
184 | void *iter_cls); | 171 | unsigned int num_results, |
172 | GNUNET_DATACACHE_Iterator iter, | ||
173 | void *iter_cls); | ||
185 | }; | 174 | }; |
186 | 175 | ||
187 | 176 | ||
@@ -195,3 +184,5 @@ struct GNUNET_DATACACHE_PluginFunctions | |||
195 | #endif | 184 | #endif |
196 | 185 | ||
197 | /** @} */ /* end of group */ | 186 | /** @} */ /* end of group */ |
187 | |||
188 | /** @} */ /* end of group addition */ | ||