diff options
author | Tristan Schwieren <tristan.schwieren@tum.de> | 2022-07-08 14:16:58 +0200 |
---|---|---|
committer | Tristan Schwieren <tristan.schwieren@tum.de> | 2022-07-08 14:16:58 +0200 |
commit | 41ed66d82fe38b460f4a04541d5a28848b0db8f2 (patch) | |
tree | 7f1ba6827372366894b4a987cd8380a1712dee9e /src/reclaim | |
parent | dcdb638c4159602b0ddb7c6729e07d044e88392b (diff) | |
download | gnunet-41ed66d82fe38b460f4a04541d5a28848b0db8f2.tar.gz gnunet-41ed66d82fe38b460f4a04541d5a28848b0db8f2.zip |
- DID lib; simplify closure
Diffstat (limited to 'src/reclaim')
-rw-r--r-- | src/reclaim/did_core.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/reclaim/did_core.c b/src/reclaim/did_core.c index 69331c6ea..949ed6a69 100644 --- a/src/reclaim/did_core.c +++ b/src/reclaim/did_core.c | |||
@@ -147,8 +147,7 @@ struct DID_create_namestore_lookup_closure | |||
147 | const char *did_document; | 147 | const char *did_document; |
148 | struct GNUNET_TIME_Relative expire_time; | 148 | struct GNUNET_TIME_Relative expire_time; |
149 | struct GNUNET_NAMESTORE_Handle *namestore_handle; | 149 | struct GNUNET_NAMESTORE_Handle *namestore_handle; |
150 | DID_action_callback *cont; | 150 | struct DID_action_return *ret; |
151 | void *cls; | ||
152 | }; | 151 | }; |
153 | 152 | ||
154 | static void | 153 | static void |
@@ -171,16 +170,15 @@ DID_create_namestore_lookup_cb (void *cls, | |||
171 | struct GNUNET_NAMESTORE_Handle *namestore_handle | 170 | struct GNUNET_NAMESTORE_Handle *namestore_handle |
172 | = ((struct DID_create_namestore_lookup_closure *) cls)->namestore_handle; | 171 | = ((struct DID_create_namestore_lookup_closure *) cls)->namestore_handle; |
173 | 172 | ||
174 | DID_action_callback *cont | 173 | struct DID_action_return *cls_record_store_cb |
175 | = ((struct DID_create_namestore_lookup_closure *) cls)->cont; | 174 | = ((struct DID_create_namestore_lookup_closure *) cls)->ret; |
176 | 175 | ||
177 | void *cls1 | 176 | free (cls); |
178 | = ((struct DID_create_namestore_lookup_closure *) cls)->cls; | ||
179 | 177 | ||
180 | if (rd_count > 0) | 178 | if (rd_count > 0) |
181 | { | 179 | { |
182 | printf ("Ego already has a DID Document. Abort.\n"); | 180 | printf ("Ego already has a DID Document. Abort.\n"); |
183 | cont (GNUNET_NO, cls1); | 181 | cls_record_store_cb->cb (GNUNET_NO, cls_record_store_cb->cls); |
184 | } | 182 | } |
185 | else { | 183 | else { |
186 | // Get public key | 184 | // Get public key |
@@ -200,12 +198,6 @@ DID_create_namestore_lookup_cb (void *cls, | |||
200 | record_data.record_type = GNUNET_GNSRECORD_typename_to_number ("TXT"), | 198 | record_data.record_type = GNUNET_GNSRECORD_typename_to_number ("TXT"), |
201 | record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 199 | record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
202 | 200 | ||
203 | // Create closure for record store callback | ||
204 | struct DID_action_return *cls_record_store_cb | ||
205 | = malloc (sizeof(struct DID_action_return)); | ||
206 | cls_record_store_cb->cb = cont; | ||
207 | cls_record_store_cb->cls = cls1; | ||
208 | |||
209 | // Store record | 201 | // Store record |
210 | GNUNET_NAMESTORE_records_store (namestore_handle, | 202 | GNUNET_NAMESTORE_records_store (namestore_handle, |
211 | zone, | 203 | zone, |
@@ -214,10 +206,7 @@ DID_create_namestore_lookup_cb (void *cls, | |||
214 | &record_data, | 206 | &record_data, |
215 | &DID_create_did_store_cb, | 207 | &DID_create_did_store_cb, |
216 | (void *) cls_record_store_cb); | 208 | (void *) cls_record_store_cb); |
217 | |||
218 | } | 209 | } |
219 | |||
220 | free (cls); | ||
221 | } | 210 | } |
222 | 211 | ||
223 | /** | 212 | /** |
@@ -226,8 +215,6 @@ DID_create_namestore_lookup_cb (void *cls, | |||
226 | * @param ego ego for which the DID should be created. | 215 | * @param ego ego for which the DID should be created. |
227 | * @param did_document did_document that should be saved in namestore. | 216 | * @param did_document did_document that should be saved in namestore. |
228 | * If did_document==NULL -> Default DID document is created. | 217 | * If did_document==NULL -> Default DID document is created. |
229 | * @param cfg_handle pointer to configuration handle | ||
230 | * @param identity_hanlde pointer to identity handle. Can be NULL if ego!=NULL | ||
231 | * @param namestore_handle | 218 | * @param namestore_handle |
232 | * @param cont callback function | 219 | * @param cont callback function |
233 | * @param cls closure | 220 | * @param cls closure |
@@ -255,13 +242,17 @@ DID_create (const struct GNUNET_IDENTITY_Ego *ego, | |||
255 | return GNUNET_NO; | 242 | return GNUNET_NO; |
256 | } | 243 | } |
257 | 244 | ||
245 | struct DID_action_return *ret | ||
246 | = malloc (sizeof(struct DID_action_return)); | ||
247 | ret->cb = cont; | ||
248 | ret->cls = cls; | ||
249 | |||
258 | struct DID_create_namestore_lookup_closure *cls_name_store_lookup_cb | 250 | struct DID_create_namestore_lookup_closure *cls_name_store_lookup_cb |
259 | = malloc (sizeof(struct DID_create_namestore_lookup_closure)); | 251 | = malloc (sizeof(struct DID_create_namestore_lookup_closure)); |
260 | cls_name_store_lookup_cb->did_document = did_document; | 252 | cls_name_store_lookup_cb->did_document = did_document; |
261 | cls_name_store_lookup_cb->expire_time = (*expire_time); | 253 | cls_name_store_lookup_cb->expire_time = (*expire_time); |
262 | cls_name_store_lookup_cb->namestore_handle = namestore_handle; | 254 | cls_name_store_lookup_cb->namestore_handle = namestore_handle; |
263 | cls_name_store_lookup_cb->cont = cont; | 255 | cls_name_store_lookup_cb->ret = ret; |
264 | cls_name_store_lookup_cb->cls = cls; | ||
265 | 256 | ||
266 | // Check if ego already has a DID Document | 257 | // Check if ego already has a DID Document |
267 | GNUNET_NAMESTORE_records_lookup (namestore_handle, | 258 | GNUNET_NAMESTORE_records_lookup (namestore_handle, |