2 This file is part of GNUnet
3 Copyright (C) 2012, 2013, 2016 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Christian Grothoff
25 * API that can be used to store naming information on a GNUnet node.
27 * @defgroup namecache Name Cache service
28 * Store naming information on a GNUnet node.
30 * Naming information can either be records for which this peer/user is
31 * authoritative, or blocks which are cached, encrypted naming data from other
34 * @see [Documentation](https://gnunet.org/namecache-subsystem)
38 #ifndef GNUNET_NAMECACHE_SERVICE_H
39 #define GNUNET_NAMECACHE_SERVICE_H
41 #include "gnunet_util_lib.h"
42 #include "gnunet_block_lib.h"
43 #include "gnunet_namestore_service.h"
48 #if 0 /* keep Emacsens' auto-indent happy */
57 struct GNUNET_NAMECACHE_QueueEntry;
60 * Handle to the namecache service.
62 struct GNUNET_NAMECACHE_Handle;
65 * Maximum size of a value that can be stored in the namecache.
67 #define GNUNET_NAMECACHE_MAX_VALUE_SIZE (63 * 1024)
71 * Connect to the namecache service.
73 * @param cfg configuration to use
74 * @return handle to use to access the service
76 struct GNUNET_NAMECACHE_Handle *
77 GNUNET_NAMECACHE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
81 * Disconnect from the namecache service (and free associated
82 * resources). Must not be called from within operation callbacks of
85 * @param h handle to the namecache
88 GNUNET_NAMECACHE_disconnect (struct GNUNET_NAMECACHE_Handle *h);
92 * Continuation called to notify client about result of the
96 * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
97 * #GNUNET_NO if content was already there or not found
98 * #GNUNET_YES (or other positive value) on success
99 * @param emsg NULL on success, otherwise an error message
102 (*GNUNET_NAMECACHE_ContinuationWithStatus) (void *cls,
109 * Store an item in the namecache. If the item is already present,
110 * it is replaced with the new record.
112 * @param h handle to the namecache
113 * @param block block to store
114 * @param cont continuation to call when done
115 * @param cont_cls closure for @a cont
116 * @return handle to abort the request, NULL on error
118 struct GNUNET_NAMECACHE_QueueEntry *
119 GNUNET_NAMECACHE_block_cache (struct GNUNET_NAMECACHE_Handle *h,
120 const struct GNUNET_GNSRECORD_Block *block,
121 GNUNET_NAMECACHE_ContinuationWithStatus cont,
126 * Process a record that was stored in the namecache.
129 * @param block block that was stored in the namecache
132 (*GNUNET_NAMECACHE_BlockProcessor) (void *cls,
133 const struct GNUNET_GNSRECORD_Block *block);
137 * Get a result for a particular key from the namecache. The processor
138 * will only be called once.
140 * @param h handle to the namecache
141 * @param derived_hash hash of zone key combined with name to lookup
142 * then at the end once with NULL
143 * @param proc function to call on the matching block, or with
144 * NULL if there is no matching block
145 * @param proc_cls closure for @a proc
146 * @return a handle that can be used to cancel, NULL on error
148 struct GNUNET_NAMECACHE_QueueEntry *
149 GNUNET_NAMECACHE_lookup_block (struct GNUNET_NAMECACHE_Handle *h,
150 const struct GNUNET_HashCode *derived_hash,
151 GNUNET_NAMECACHE_BlockProcessor proc,
156 * Cancel a namecache operation. The final callback from the
157 * operation must not have been done yet. Must be called on any
158 * namecache operation that has not yet completed prior to calling
159 * #GNUNET_NAMECACHE_disconnect.
161 * @param qe operation to cancel
164 GNUNET_NAMECACHE_cancel (struct GNUNET_NAMECACHE_QueueEntry *qe);
167 #if 0 /* keep Emacsens' auto-indent happy */
176 /** @} */ /* end of group */