diff options
Diffstat (limited to 'src/datastore/plugin_datastore_template.c')
-rw-r--r-- | src/datastore/plugin_datastore_template.c | 110 |
1 files changed, 48 insertions, 62 deletions
diff --git a/src/datastore/plugin_datastore_template.c b/src/datastore/plugin_datastore_template.c index 40b191538..6228e8c0c 100644 --- a/src/datastore/plugin_datastore_template.c +++ b/src/datastore/plugin_datastore_template.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2009, 2011 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -47,7 +47,8 @@ struct Plugin | |||
47 | * @param cls our "struct Plugin*" | 47 | * @param cls our "struct Plugin*" |
48 | * @return number of bytes used on disk | 48 | * @return number of bytes used on disk |
49 | */ | 49 | */ |
50 | static unsigned long long template_plugin_get_size (void *cls) | 50 | static unsigned long long |
51 | template_plugin_estimate_size (void *cls) | ||
51 | { | 52 | { |
52 | GNUNET_break (0); | 53 | GNUNET_break (0); |
53 | return 0; | 54 | return 0; |
@@ -88,30 +89,11 @@ template_plugin_put (void *cls, | |||
88 | 89 | ||
89 | 90 | ||
90 | /** | 91 | /** |
91 | * Function invoked on behalf of a "PluginIterator" | 92 | * Get one of the results for a particular key in the datastore. |
92 | * asking the database plugin to call the iterator | ||
93 | * with the next item. | ||
94 | * | ||
95 | * @param next_cls whatever argument was given | ||
96 | * to the PluginIterator as "next_cls". | ||
97 | * @param end_it set to GNUNET_YES if we | ||
98 | * should terminate the iteration early | ||
99 | * (iterator should be still called once more | ||
100 | * to signal the end of the iteration). | ||
101 | */ | ||
102 | static void | ||
103 | template_plugin_next_request (void *next_cls, | ||
104 | int end_it) | ||
105 | { | ||
106 | GNUNET_break (0); | ||
107 | } | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Iterate over the results for a particular key | ||
112 | * in the datastore. | ||
113 | * | 93 | * |
114 | * @param cls closure | 94 | * @param cls closure |
95 | * @param offset offset of the result (mod #num-results); | ||
96 | * specific ordering does not matter for the offset | ||
115 | * @param key maybe NULL (to match all entries) | 97 | * @param key maybe NULL (to match all entries) |
116 | * @param vhash hash of the value, maybe NULL (to | 98 | * @param vhash hash of the value, maybe NULL (to |
117 | * match all values that have the right key). | 99 | * match all values that have the right key). |
@@ -120,16 +102,17 @@ template_plugin_next_request (void *next_cls, | |||
120 | * there may be! | 102 | * there may be! |
121 | * @param type entries of which type are relevant? | 103 | * @param type entries of which type are relevant? |
122 | * Use 0 for any type. | 104 | * Use 0 for any type. |
123 | * @param iter function to call on each matching value; | 105 | * @param proc function to call on each matching value; |
124 | * will be called once with a NULL value at the end | 106 | * will be called with NULL if nothing matches |
125 | * @param iter_cls closure for iter | 107 | * @param proc_cls closure for proc |
126 | */ | 108 | */ |
127 | static void | 109 | static void |
128 | template_plugin_get (void *cls, | 110 | template_plugin_get_key (void *cls, |
129 | const GNUNET_HashCode * key, | 111 | uint64_t offset, |
130 | const GNUNET_HashCode * vhash, | 112 | const GNUNET_HashCode * key, |
131 | enum GNUNET_BLOCK_Type type, | 113 | const GNUNET_HashCode * vhash, |
132 | PluginIterator iter, void *iter_cls) | 114 | enum GNUNET_BLOCK_Type type, |
115 | PluginDatumProcessor proc, void *proc_cls) | ||
133 | { | 116 | { |
134 | GNUNET_break (0); | 117 | GNUNET_break (0); |
135 | } | 118 | } |
@@ -137,34 +120,35 @@ template_plugin_get (void *cls, | |||
137 | 120 | ||
138 | 121 | ||
139 | /** | 122 | /** |
140 | * Get a random item for replication. Returns a single, not expired, random item | 123 | * Get a random item for replication. Returns a single, not expired, |
141 | * from those with the highest replication counters. The item's | 124 | * random item from those with the highest replication counters. The |
142 | * replication counter is decremented by one IF it was positive before. | 125 | * item's replication counter is decremented by one IF it was positive |
143 | * Call 'iter' with all values ZERO or NULL if the datastore is empty. | 126 | * before. Call 'proc' with all values ZERO or NULL if the datastore |
127 | * is empty. | ||
144 | * | 128 | * |
145 | * @param cls closure | 129 | * @param cls closure |
146 | * @param iter function to call the value (once only). | 130 | * @param proc function to call the value (once only). |
147 | * @param iter_cls closure for iter | 131 | * @param proc_cls closure for proc |
148 | */ | 132 | */ |
149 | static void | 133 | static void |
150 | template_plugin_replication_get (void *cls, | 134 | template_plugin_get_replication (void *cls, |
151 | PluginIterator iter, void *iter_cls) | 135 | PluginDatumProcessor proc, void *proc_cls) |
152 | { | 136 | { |
153 | GNUNET_break (0); | 137 | GNUNET_break (0); |
154 | } | 138 | } |
155 | 139 | ||
156 | 140 | ||
157 | /** | 141 | /** |
158 | * Get a random item for expiration. | 142 | * Get a random item for expiration. Call 'proc' with all values ZERO |
159 | * Call 'iter' with all values ZERO or NULL if the datastore is empty. | 143 | * or NULL if the datastore is empty. |
160 | * | 144 | * |
161 | * @param cls closure | 145 | * @param cls closure |
162 | * @param iter function to call the value (once only). | 146 | * @param proc function to call the value (once only). |
163 | * @param iter_cls closure for iter | 147 | * @param proc_cls closure for proc |
164 | */ | 148 | */ |
165 | static void | 149 | static void |
166 | template_plugin_expiration_get (void *cls, | 150 | template_plugin_get_expiration (void *cls, |
167 | PluginIterator iter, void *iter_cls) | 151 | PluginDatumProcessor proc, void *proc_cls) |
168 | { | 152 | { |
169 | GNUNET_break (0); | 153 | GNUNET_break (0); |
170 | } | 154 | } |
@@ -196,7 +180,8 @@ template_plugin_expiration_get (void *cls, | |||
196 | static int | 180 | static int |
197 | template_plugin_update (void *cls, | 181 | template_plugin_update (void *cls, |
198 | uint64_t uid, | 182 | uint64_t uid, |
199 | int delta, struct GNUNET_TIME_Absolute expire, | 183 | int delta, |
184 | struct GNUNET_TIME_Absolute expire, | ||
200 | char **msg) | 185 | char **msg) |
201 | { | 186 | { |
202 | GNUNET_break (0); | 187 | GNUNET_break (0); |
@@ -206,21 +191,23 @@ template_plugin_update (void *cls, | |||
206 | 191 | ||
207 | 192 | ||
208 | /** | 193 | /** |
209 | * Select a subset of the items in the datastore and call | 194 | * Call the given processor on an item with zero anonymity. |
210 | * the given iterator for each of them. | ||
211 | * | 195 | * |
212 | * @param cls our "struct Plugin*" | 196 | * @param cls our "struct Plugin*" |
197 | * @param offset offset of the result (mod #num-results); | ||
198 | * specific ordering does not matter for the offset | ||
213 | * @param type entries of which type should be considered? | 199 | * @param type entries of which type should be considered? |
214 | * Use 0 for any type. | 200 | * Use 0 for any type. |
215 | * @param iter function to call on each matching value; | 201 | * @param proc function to call on each matching value; |
216 | * will be called once with a NULL value at the end | 202 | * will be called with NULL if no value matches |
217 | * @param iter_cls closure for iter | 203 | * @param proc_cls closure for proc |
218 | */ | 204 | */ |
219 | static void | 205 | static void |
220 | template_plugin_iter_zero_anonymity (void *cls, | 206 | template_plugin_get_zero_anonymity (void *cls, |
221 | enum GNUNET_BLOCK_Type type, | 207 | uint64_t offset, |
222 | PluginIterator iter, | 208 | enum GNUNET_BLOCK_Type type, |
223 | void *iter_cls) | 209 | PluginDatumProcessor proc, |
210 | void *proc_cls) | ||
224 | { | 211 | { |
225 | GNUNET_break (0); | 212 | GNUNET_break (0); |
226 | } | 213 | } |
@@ -253,14 +240,13 @@ libgnunet_plugin_datastore_template_init (void *cls) | |||
253 | plugin->env = env; | 240 | plugin->env = env; |
254 | api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions)); | 241 | api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions)); |
255 | api->cls = plugin; | 242 | api->cls = plugin; |
256 | api->get_size = &template_plugin_get_size; | 243 | api->estimate_size = &template_plugin_estimate_size; |
257 | api->put = &template_plugin_put; | 244 | api->put = &template_plugin_put; |
258 | api->next_request = &template_plugin_next_request; | ||
259 | api->get = &template_plugin_get; | ||
260 | api->replication_get = &template_plugin_replication_get; | ||
261 | api->expiration_get = &template_plugin_expiration_get; | ||
262 | api->update = &template_plugin_update; | 245 | api->update = &template_plugin_update; |
263 | api->iter_zero_anonymity = &template_plugin_iter_zero_anonymity; | 246 | api->get_key = &template_plugin_get_key; |
247 | api->get_replication = &template_plugin_get_replication; | ||
248 | api->get_expiration = &template_plugin_get_expiration; | ||
249 | api->get_zero_anonymity = &template_plugin_get_zero_anonymity; | ||
264 | api->drop = &template_plugin_drop; | 250 | api->drop = &template_plugin_drop; |
265 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, | 251 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, |
266 | "template", _("Template database running\n")); | 252 | "template", _("Template database running\n")); |