diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-11-21 17:08:39 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-11-21 17:08:39 +0100 |
commit | d237b33a42048e26f409375af65ec275ae0eb027 (patch) | |
tree | 13e65c716a2df41193540f318621d7655962f954 /src/include | |
parent | 92c6328195c3bed9abbd56625fcab5952869289c (diff) | |
download | gnunet-d237b33a42048e26f409375af65ec275ae0eb027.tar.gz gnunet-d237b33a42048e26f409375af65ec275ae0eb027.zip |
modernize namestore postgres plugin, a bit
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_namestore_plugin.h | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h index 1df0a5eb0..4f08ccbcf 100644 --- a/src/include/gnunet_namestore_plugin.h +++ b/src/include/gnunet_namestore_plugin.h | |||
@@ -88,12 +88,12 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
88 | * @param rd array of records with data to store | 88 | * @param rd array of records with data to store |
89 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 89 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
90 | */ | 90 | */ |
91 | int | 91 | enum GNUNET_GenericReturnValue |
92 | (*store_records) (void *cls, | 92 | (*store_records)(void *cls, |
93 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 93 | const struct GNUNET_IDENTITY_PrivateKey *zone, |
94 | const char *label, | 94 | const char *label, |
95 | unsigned int rd_count, | 95 | unsigned int rd_count, |
96 | const struct GNUNET_GNSRECORD_Data *rd); | 96 | const struct GNUNET_GNSRECORD_Data *rd); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Lookup records in the datastore for which we are the authority. | 99 | * Lookup records in the datastore for which we are the authority. |
@@ -105,12 +105,12 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
105 | * @param iter_cls closure for @a iter | 105 | * @param iter_cls closure for @a iter |
106 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | 106 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR |
107 | */ | 107 | */ |
108 | int | 108 | enum GNUNET_GenericReturnValue |
109 | (*lookup_records) (void *cls, | 109 | (*lookup_records)(void *cls, |
110 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 110 | const struct GNUNET_IDENTITY_PrivateKey *zone, |
111 | const char *label, | 111 | const char *label, |
112 | GNUNET_NAMESTORE_RecordIterator iter, | 112 | GNUNET_NAMESTORE_RecordIterator iter, |
113 | void *iter_cls); | 113 | void *iter_cls); |
114 | 114 | ||
115 | 115 | ||
116 | /** | 116 | /** |
@@ -127,13 +127,13 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
127 | * @param iter_cls closure for @a iter | 127 | * @param iter_cls closure for @a iter |
128 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error | 128 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no more results, #GNUNET_SYSERR on error |
129 | */ | 129 | */ |
130 | int | 130 | enum GNUNET_GenericReturnValue |
131 | (*iterate_records) (void *cls, | 131 | (*iterate_records)(void *cls, |
132 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 132 | const struct GNUNET_IDENTITY_PrivateKey *zone, |
133 | uint64_t serial, | 133 | uint64_t serial, |
134 | uint64_t limit, | 134 | uint64_t limit, |
135 | GNUNET_NAMESTORE_RecordIterator iter, | 135 | GNUNET_NAMESTORE_RecordIterator iter, |
136 | void *iter_cls); | 136 | void *iter_cls); |
137 | 137 | ||
138 | 138 | ||
139 | /** | 139 | /** |
@@ -147,12 +147,12 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
147 | * @param iter_cls closure for @a iter | 147 | * @param iter_cls closure for @a iter |
148 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error | 148 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error |
149 | */ | 149 | */ |
150 | int | 150 | enum GNUNET_GenericReturnValue |
151 | (*zone_to_name) (void *cls, | 151 | (*zone_to_name)(void *cls, |
152 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 152 | const struct GNUNET_IDENTITY_PrivateKey *zone, |
153 | const struct GNUNET_IDENTITY_PublicKey *value_zone, | 153 | const struct GNUNET_IDENTITY_PublicKey *value_zone, |
154 | GNUNET_NAMESTORE_RecordIterator iter, | 154 | GNUNET_NAMESTORE_RecordIterator iter, |
155 | void *iter_cls); | 155 | void *iter_cls); |
156 | 156 | ||
157 | /** Transaction-based API draft **/ | 157 | /** Transaction-based API draft **/ |
158 | 158 | ||
@@ -164,7 +164,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
164 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 164 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
165 | */ | 165 | */ |
166 | enum GNUNET_GenericReturnValue | 166 | enum GNUNET_GenericReturnValue |
167 | (*transaction_begin) (void *cls, char **emsg); | 167 | (*transaction_begin)(void *cls, char **emsg); |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Abort and roll back a transaction in the database | 170 | * Abort and roll back a transaction in the database |
@@ -174,7 +174,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
174 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 174 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
175 | */ | 175 | */ |
176 | enum GNUNET_GenericReturnValue | 176 | enum GNUNET_GenericReturnValue |
177 | (*transaction_rollback) (void *cls, char **emsg); | 177 | (*transaction_rollback)(void *cls, char **emsg); |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * Commit a transaction in the database | 180 | * Commit a transaction in the database |
@@ -184,7 +184,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
184 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 184 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
185 | */ | 185 | */ |
186 | enum GNUNET_GenericReturnValue | 186 | enum GNUNET_GenericReturnValue |
187 | (*transaction_commit) (void *cls, char **emsg); | 187 | (*transaction_commit)(void *cls, char **emsg); |
188 | 188 | ||
189 | /** | 189 | /** |
190 | * Edit records in the datastore for which we are the authority. | 190 | * Edit records in the datastore for which we are the authority. |
@@ -198,35 +198,32 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
198 | * @param iter_cls closure for @a iter | 198 | * @param iter_cls closure for @a iter |
199 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR | 199 | * @return #GNUNET_OK on success, #GNUNET_NO for no results, else #GNUNET_SYSERR |
200 | */ | 200 | */ |
201 | int | 201 | enum GNUNET_GenericReturnValue |
202 | (*edit_records) (void *cls, | 202 | (*edit_records)(void *cls, |
203 | const struct GNUNET_IDENTITY_PrivateKey *zone, | 203 | const struct GNUNET_IDENTITY_PrivateKey *zone, |
204 | const char *label, | 204 | const char *label, |
205 | GNUNET_NAMESTORE_RecordIterator iter, | 205 | GNUNET_NAMESTORE_RecordIterator iter, |
206 | void *iter_cls); | 206 | void *iter_cls); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * Setup the database. | 209 | * Setup the database. |
210 | * Note that this will also fail if the database is already initialized. | ||
211 | * See reset_database(). | ||
212 | * | 210 | * |
213 | * @param cls closure (internal context for the plugin) | 211 | * @param cls closure (internal context for the plugin) |
214 | * @param emsg error message on failure. Will be allocated, must be freed. | ||
215 | * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR | 212 | * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR |
216 | */ | 213 | */ |
217 | int | 214 | enum GNUNET_GenericReturnValue |
218 | (*initialize_database) (void *cls, char **emsg); | 215 | (*create_tables)(void *cls); |
216 | |||
219 | 217 | ||
220 | /** | 218 | /** |
221 | * Re-initializes the database. | 219 | * Drop existing tables. |
222 | * DANGEROUS: All existing data in the dabase will be lost! | 220 | * DANGEROUS: All existing data in the dabase will be lost! |
223 | * | 221 | * |
224 | * @param cls closure (internal context for the plugin) | 222 | * @param cls closure (internal context for the plugin) |
225 | * @param emsg error message on failure. Will be allocated, must be freed. | ||
226 | * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR | 223 | * @return #GNUNET_OK on success, else fails with #GNUNET_SYSERR |
227 | */ | 224 | */ |
228 | int | 225 | enum GNUNET_GenericReturnValue |
229 | (*reset_database) (void *cls, char **emsg); | 226 | (*drop_tables)(void *cls); |
230 | }; | 227 | }; |
231 | 228 | ||
232 | 229 | ||