2 This file is part of GNUnet.
3 (C) 2013 Christian Grothoff (and other contributing authors)
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_psycstore_service.h
23 * @brief PSYCstore service; implements persistent storage for the PSYC service
25 * @author Christian Grothoff
27 #ifndef GNUNET_PSYCSTORE_SERVICE_H
28 #define GNUNET_PSYCSTORE_SERVICE_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include "gnunet_util_lib.h"
41 * Version number of GNUnet PSYCstore API.
43 #define GNUNET_PSYCSTORE_VERSION 0x00000000
46 * Handle for a PSYCstore
48 struct GNUNET_PSYCSTORE_Handle;
52 * Connect to the PSYCstore service.
54 * @param cfg Configuration to use.
56 * @return Handle for the connecton.
58 struct GNUNET_PSYCSTORE_Handle *
59 GNUNET_PSYCSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
63 * Disconnect from the PSYCstore service.
65 * @param h Handle for the connection.
68 GNUNET_PSYCSTORE_disconnect (struct GNUNET_PSYCSTORE_Handle *h);
72 * Handle for an operation on the PSYCSTORE (useful to cancel the operation).
74 struct GNUNET_PSYCSTORE_OperationHandle;
79 * @param result GNUNET_SYSERR on error,
80 * GNUNET_YES on success or if the peer was a member,
81 * GNUNET_NO if the peer was not a member
83 typedef void (*GNUNET_PSYCSTORE_ContinuationCallback)(void *cls,
87 * Store join/leave events for a PSYC channel in order to be able to answer
88 * membership test queries later.
90 * @param h Handle for the PSYCstore.
91 * @param channel_id ID of the channel where the event happened.
92 * @param message_id ID of the message in which this event was announced.
93 * @param peer Identity of joining/leaving peer.
94 * @param did_join GNUNET_YES on join, GNUNET_NO on leave.
95 * @param ccb Callback to call with the result of the storage operation.
96 * @param ccb_cls Closure for the callback.
98 * @return Operation handle that can be used to cancel the operation.
100 struct GNUNET_PSYCSTORE_OperationHandle *
101 GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h,
102 const struct GNUNET_HashCode *channel_id,
104 const struct GNUNET_PeerIdentity *peer,
106 GNUNET_PSYCSTORE_ContinuationCallback ccb,
111 * Test if a peer was a member of the channel when the message with the
112 * specified ID was sent to the channel. This is useful in case of
113 * retransmissions to check if the peer was authorized to see the requested
116 * @param h Handle for the PSYCstore.
117 * @param channel_id The channel we are interested in.
118 * @param message_id Message ID to check.
119 * @param peer Peer whose membership to check.
120 * @param ccb Callback to call with the test result.
121 * @param ccb_cls Closure for the callback.
123 * @return Operation handle that can be used to cancel the operation.
124 */struct GNUNET_PSYCSTORE_OperationHandle *
125 GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
126 const struct GNUNET_HashCode *channel_id,
128 const struct GNUNET_PeerIdentity *peer,
129 GNUNET_PSYCSTORE_ContinuationCallback ccb,
133 struct GNUNET_PSYCSTORE_OperationHandle *
134 GNUNET_PSYCSTORE_message_store (struct GNUNET_PSYCSTORE_Handle *h,
135 const struct GNUNET_HashCode *channel_id,
136 const struct GNUNET_MULTICAST_MessageHeader *message,
137 GNUNET_PSYCSTORE_ContinuationCallback ccb,
141 typedef void (*GNUNET_PSYCSTORE_MessageResultCallback)(void *cls,
143 const struct GNUNET_MULTICAST_MessageHeader *message);
146 struct GNUNET_PSYCSTORE_OperationHandle *
147 GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
148 const struct GNUNET_HashCode *channel_id,
150 GNUNET_PSYCSTORE_MessageResultCallback rcb,
154 struct GNUNET_PSYCSTORE_OperationHandle *
155 GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h,
156 const struct GNUNET_HashCode *channel_id,
157 GNUNET_PSYCSTORE_MessageResultCallback rcb,
161 struct GNUNET_PSYCSTORE_OperationHandle *
162 GNUNET_PSYCSTORE_state_set (struct GNUNET_PSYCSTORE_Handle *h,
163 const struct GNUNET_HashCode *channel_id,
164 const char *state_name,
167 GNUNET_PSYCSTORE_ContinuationCallback ccb,
171 typedef void (*GNUNET_PSYCSTORE_StateResultCallback)(void *cls,
172 const char *state_name,
177 struct GNUNET_PSYCSTORE_OperationHandle *
178 GNUNET_PSYCSTORE_state_get (struct GNUNET_PSYCSTORE_Handle *h,
179 const struct GNUNET_HashCode *channel_id,
180 const char *state_name,
181 GNUNET_PSYCSTORE_StateResultCallback rcb,
185 struct GNUNET_PSYCSTORE_OperationHandle *
186 GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h,
187 const struct GNUNET_HashCode *channel_id,
188 GNUNET_PSYCSTORE_StateResultCallback rcb,
193 GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *oh);
198 #if 0 /* keep Emacsens' auto-indent happy */
205 /* ifndef GNUNET_PSYCSTORE_SERVICE_H */
207 /* end of gnunet_psycstore_service.h */