2 This file is part of GNUnet
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 include/gnunet_peerstore_service.h
23 * @brief API to the peerstore service
24 * @author Omar Tarabai
26 #ifndef GNUNET_PEERSTORE_SERVICE_H
27 #define GNUNET_PEERSTORE_SERVICE_H
30 #include "gnunet_util_lib.h"
35 #if 0 /* keep Emacsens' auto-indent happy */
41 * Handle to the peerstore service.
43 struct GNUNET_PEERSTORE_Handle;
46 * Context for a store request
48 struct GNUNET_PEERSTORE_StoreContext;
51 * Single PEERSTORE record
53 struct GNUNET_PEERSTORE_Record
57 * Responsible sub system string
64 struct GNUNET_PeerIdentity *peer;
77 * Size of 'value' BLOB
82 * Expiry time of entry
84 struct GNUNET_TIME_Absolute *expiry;
89 * Continuation called with a status result.
92 * @param success #GNUNET_OK or #GNUNET_SYSERR
94 typedef void (*GNUNET_PEERSTORE_Continuation)(void *cls, int success);
97 * Function called by for each matching record.
100 * @param peer peer identity
101 * @param sub_system name of the GNUnet sub system responsible
102 * @param value stored value
103 * @param size size of stored value
104 * @return #GNUNET_YES to continue iterating, #GNUNET_NO to stop
106 typedef int (*GNUNET_PEERSTORE_Processor) (void *cls,
107 const char *sub_system,
108 const struct GNUNET_PeerIdentity *peer,
112 struct GNUNET_TIME_Absolute expiry);
115 * Connect to the PEERSTORE service.
117 * @return NULL on error
119 struct GNUNET_PEERSTORE_Handle *
120 GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
123 * Disconnect from the PEERSTORE service
125 * @param h handle to disconnect
128 GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h);
131 * Store a new entry in the PEERSTORE
133 * @param h Handle to the PEERSTORE service
134 * @param sub_system name of the sub system
135 * @param peer Peer Identity
136 * @param key entry key
137 * @param value entry value BLOB
138 * @param size size of 'value'
139 * @param lifetime relative time after which the entry is (possibly) deleted
140 * @param cont Continuation function after the store request is processed
141 * @param cont_cls Closure for 'cont'
143 struct GNUNET_PEERSTORE_StoreContext *
144 GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h,
145 const char *sub_system,
146 const struct GNUNET_PeerIdentity *peer,
150 struct GNUNET_TIME_Absolute expiry,
151 GNUNET_PEERSTORE_Continuation cont,
155 * Cancel a store request
157 * @param sc Store request context
160 GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc);
162 #if 0 /* keep Emacsens' auto-indent happy */