diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-07-24 12:44:24 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-07-24 12:44:24 +0000 |
commit | c057bd312c783e0a2f3783dfd888a66f490b0a30 (patch) | |
tree | ff87b7bf7189a723045d7c851d2d383b786724ec /src | |
parent | f2594744c121f45f3b36867b051220e7186d6f9b (diff) | |
download | gnunet-c057bd312c783e0a2f3783dfd888a66f490b0a30.tar.gz gnunet-c057bd312c783e0a2f3783dfd888a66f490b0a30.zip |
peerstore: doxygen
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_peerstore_service.h | 33 | ||||
-rw-r--r-- | src/peerstore/gnunet-service-peerstore.c | 52 | ||||
-rw-r--r-- | src/peerstore/peerstore_api.c | 41 | ||||
-rw-r--r-- | src/peerstore/peerstore_common.c | 15 | ||||
-rw-r--r-- | src/peerstore/peerstore_common.h | 15 | ||||
-rw-r--r-- | src/peerstore/plugin_peerstore_sqlite.c | 21 |
6 files changed, 96 insertions, 81 deletions
diff --git a/src/include/gnunet_peerstore_service.h b/src/include/gnunet_peerstore_service.h index ca751af96..fcd0bb5f2 100644 --- a/src/include/gnunet_peerstore_service.h +++ b/src/include/gnunet_peerstore_service.h | |||
@@ -134,7 +134,8 @@ GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | |||
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH requests | 136 | * Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH requests |
137 | * will be canceled. Any pending STORE requests will depend on @snyc_first flag. | 137 | * will be canceled. |
138 | * Any pending STORE requests will depend on @e snyc_first flag. | ||
138 | * | 139 | * |
139 | * @param h handle to disconnect | 140 | * @param h handle to disconnect |
140 | * @param sync_first send any pending STORE requests before disconnecting | 141 | * @param sync_first send any pending STORE requests before disconnecting |
@@ -143,30 +144,32 @@ void | |||
143 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first); | 144 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first); |
144 | 145 | ||
145 | /** | 146 | /** |
146 | * Store a new entry in the PEERSTORE | 147 | * Store a new entry in the PEERSTORE. |
148 | * Note that stored entries can be lost in some cases | ||
149 | * such as power failure. | ||
147 | * | 150 | * |
148 | * @param h Handle to the PEERSTORE service | 151 | * @param h Handle to the PEERSTORE service |
149 | * @param sub_system name of the sub system | 152 | * @param sub_system name of the sub system |
150 | * @param peer Peer Identity | 153 | * @param peer Peer Identity |
151 | * @param key entry key | 154 | * @param key entry key |
152 | * @param value entry value BLOB | 155 | * @param value entry value BLOB |
153 | * @param size size of 'value' | 156 | * @param size size of @e value |
154 | * @param expiry absolute time after which the entry is (possibly) deleted | 157 | * @param expiry absolute time after which the entry is (possibly) deleted |
155 | * @param options store operation option | 158 | * @param options options specific to the storage operation |
156 | * @param cont Continuation function after the store request is processed | 159 | * @param cont Continuation function after the store request is sent |
157 | * @param cont_cls Closure for 'cont' | 160 | * @param cont_cls Closure for 'cont' |
158 | */ | 161 | */ |
159 | struct GNUNET_PEERSTORE_StoreContext * | 162 | struct GNUNET_PEERSTORE_StoreContext * |
160 | GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h, | 163 | GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h, |
161 | const char *sub_system, | 164 | const char *sub_system, |
162 | const struct GNUNET_PeerIdentity *peer, | 165 | const struct GNUNET_PeerIdentity *peer, |
163 | const char *key, | 166 | const char *key, |
164 | const void *value, | 167 | const void *value, |
165 | size_t size, | 168 | size_t size, |
166 | struct GNUNET_TIME_Absolute expiry, | 169 | struct GNUNET_TIME_Absolute expiry, |
167 | enum GNUNET_PEERSTORE_StoreOption options, | 170 | enum GNUNET_PEERSTORE_StoreOption options, |
168 | GNUNET_PEERSTORE_Continuation cont, | 171 | GNUNET_PEERSTORE_Continuation cont, |
169 | void *cont_cls); | 172 | void *cont_cls); |
170 | 173 | ||
171 | /** | 174 | /** |
172 | * Cancel a store request | 175 | * Cancel a store request |
@@ -226,7 +229,7 @@ GNUNET_PEERSTORE_watch (struct GNUNET_PEERSTORE_Handle *h, | |||
226 | /** | 229 | /** |
227 | * Cancel a watch request | 230 | * Cancel a watch request |
228 | * | 231 | * |
229 | * @wc handle to the watch request | 232 | * @param wc handle to the watch request |
230 | */ | 233 | */ |
231 | void | 234 | void |
232 | GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc); | 235 | GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc); |
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c index b7128dda5..c93d2cc95 100644 --- a/src/peerstore/gnunet-service-peerstore.c +++ b/src/peerstore/gnunet-service-peerstore.c | |||
@@ -207,26 +207,29 @@ handle_client_disconnect (void *cls, | |||
207 | * Function called by for each matching record. | 207 | * Function called by for each matching record. |
208 | * | 208 | * |
209 | * @param cls closure | 209 | * @param cls closure |
210 | * @param peer peer identity | 210 | * @param record peerstore record found |
211 | * @param sub_system name of the GNUnet sub system responsible | 211 | * @param emsg error message or NULL if no errors |
212 | * @param value stored value | 212 | * @return #GNUNET_YES to continue iteration |
213 | * @param size size of stored value | ||
214 | */ | 213 | */ |
215 | static int record_iterator(void *cls, | 214 | static int |
216 | struct GNUNET_PEERSTORE_Record *record, | 215 | record_iterator (void *cls, |
217 | char *emsg) | 216 | struct GNUNET_PEERSTORE_Record *record, |
217 | char *emsg) | ||
218 | { | 218 | { |
219 | struct GNUNET_SERVER_Client *client = cls; | 219 | struct GNUNET_SERVER_Client *client = cls; |
220 | struct StoreRecordMessage *srm; | 220 | struct StoreRecordMessage *srm; |
221 | 221 | ||
222 | srm = PEERSTORE_create_record_message(record->sub_system, | 222 | srm = |
223 | record->peer, | 223 | PEERSTORE_create_record_message(record->sub_system, |
224 | record->key, | 224 | record->peer, |
225 | record->value, | 225 | record->key, |
226 | record->value_size, | 226 | record->value, |
227 | record->expiry, | 227 | record->value_size, |
228 | GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_RECORD); | 228 | record->expiry, |
229 | GNUNET_SERVER_notification_context_unicast(nc, client, (struct GNUNET_MessageHeader *)srm, GNUNET_NO); | 229 | GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_RECORD); |
230 | GNUNET_SERVER_notification_context_unicast (nc, client, | ||
231 | (struct GNUNET_MessageHeader *)srm, | ||
232 | GNUNET_NO); | ||
230 | GNUNET_free(srm); | 233 | GNUNET_free(srm); |
231 | return GNUNET_YES; | 234 | return GNUNET_YES; |
232 | } | 235 | } |
@@ -348,17 +351,18 @@ static void handle_iterate (void *cls, | |||
348 | GNUNET_SERVER_receive_done(client, GNUNET_SYSERR); | 351 | GNUNET_SERVER_receive_done(client, GNUNET_SYSERR); |
349 | return; | 352 | return; |
350 | } | 353 | } |
351 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Iterate request: ss `%s', peer `%s', key `%s'\n", | 354 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
352 | record->sub_system, | 355 | "Iterate request: ss `%s', peer `%s', key `%s'\n", |
353 | (NULL == record->peer) ? "NULL" : GNUNET_i2s(record->peer), | 356 | record->sub_system, |
354 | (NULL == record->key) ? "NULL" : record->key); | 357 | (NULL == record->peer) ? "NULL" : GNUNET_i2s(record->peer), |
358 | (NULL == record->key) ? "NULL" : record->key); | ||
355 | GNUNET_SERVER_notification_context_add(nc, client); | 359 | GNUNET_SERVER_notification_context_add(nc, client); |
356 | if(GNUNET_OK == db->iterate_records(db->cls, | 360 | if(GNUNET_OK == db->iterate_records(db->cls, |
357 | record->sub_system, | 361 | record->sub_system, |
358 | record->peer, | 362 | record->peer, |
359 | record->key, | 363 | record->key, |
360 | &record_iterator, | 364 | &record_iterator, |
361 | client)) | 365 | client)) |
362 | { | 366 | { |
363 | endmsg = GNUNET_new(struct GNUNET_MessageHeader); | 367 | endmsg = GNUNET_new(struct GNUNET_MessageHeader); |
364 | endmsg->size = htons(sizeof(struct GNUNET_MessageHeader)); | 368 | endmsg->size = htons(sizeof(struct GNUNET_MessageHeader)); |
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index 81d287b53..3c67846e6 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -454,7 +454,8 @@ GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
454 | 454 | ||
455 | /** | 455 | /** |
456 | * Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH requests | 456 | * Disconnect from the PEERSTORE service. Any pending ITERATE and WATCH requests |
457 | * will be canceled. Any pending STORE requests will depend on @snyc_first flag. | 457 | * will be canceled. |
458 | * Any pending STORE requests will depend on @e snyc_first flag. | ||
458 | * | 459 | * |
459 | * @param h handle to disconnect | 460 | * @param h handle to disconnect |
460 | * @param sync_first send any pending STORE requests before disconnecting | 461 | * @param sync_first send any pending STORE requests before disconnecting |
@@ -556,22 +557,23 @@ GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc) | |||
556 | * @param peer Peer Identity | 557 | * @param peer Peer Identity |
557 | * @param key entry key | 558 | * @param key entry key |
558 | * @param value entry value BLOB | 559 | * @param value entry value BLOB |
559 | * @param size size of 'value' | 560 | * @param size size of @e value |
560 | * @param expiry absolute time after which the entry is (possibly) deleted | 561 | * @param expiry absolute time after which the entry is (possibly) deleted |
562 | * @param options options specific to the storage operation | ||
561 | * @param cont Continuation function after the store request is sent | 563 | * @param cont Continuation function after the store request is sent |
562 | * @param cont_cls Closure for 'cont' | 564 | * @param cont_cls Closure for 'cont' |
563 | */ | 565 | */ |
564 | struct GNUNET_PEERSTORE_StoreContext * | 566 | struct GNUNET_PEERSTORE_StoreContext * |
565 | GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h, | 567 | GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h, |
566 | const char *sub_system, | 568 | const char *sub_system, |
567 | const struct GNUNET_PeerIdentity *peer, | 569 | const struct GNUNET_PeerIdentity *peer, |
568 | const char *key, | 570 | const char *key, |
569 | const void *value, | 571 | const void *value, |
570 | size_t size, | 572 | size_t size, |
571 | struct GNUNET_TIME_Absolute expiry, | 573 | struct GNUNET_TIME_Absolute expiry, |
572 | enum GNUNET_PEERSTORE_StoreOption options, | 574 | enum GNUNET_PEERSTORE_StoreOption options, |
573 | GNUNET_PEERSTORE_Continuation cont, | 575 | GNUNET_PEERSTORE_Continuation cont, |
574 | void *cont_cls) | 576 | void *cont_cls) |
575 | { | 577 | { |
576 | struct GNUNET_MQ_Envelope *ev; | 578 | struct GNUNET_MQ_Envelope *ev; |
577 | struct GNUNET_PEERSTORE_StoreContext *sc; | 579 | struct GNUNET_PEERSTORE_StoreContext *sc; |
@@ -580,13 +582,13 @@ GNUNET_PEERSTORE_store (struct GNUNET_PEERSTORE_Handle *h, | |||
580 | "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n", | 582 | "Storing value (size: %lu) for subsytem `%s', peer `%s', key `%s'\n", |
581 | size, sub_system, GNUNET_i2s (peer), key); | 583 | size, sub_system, GNUNET_i2s (peer), key); |
582 | ev = PEERSTORE_create_record_mq_envelope(sub_system, | 584 | ev = PEERSTORE_create_record_mq_envelope(sub_system, |
583 | peer, | 585 | peer, |
584 | key, | 586 | key, |
585 | value, | 587 | value, |
586 | size, | 588 | size, |
587 | &expiry, | 589 | &expiry, |
588 | options, | 590 | options, |
589 | GNUNET_MESSAGE_TYPE_PEERSTORE_STORE); | 591 | GNUNET_MESSAGE_TYPE_PEERSTORE_STORE); |
590 | sc = GNUNET_new(struct GNUNET_PEERSTORE_StoreContext); | 592 | sc = GNUNET_new(struct GNUNET_PEERSTORE_StoreContext); |
591 | sc->ev = ev; | 593 | sc->ev = ev; |
592 | sc->cont = cont; | 594 | sc->cont = cont; |
@@ -681,6 +683,7 @@ static void iterate_request_sent (void *cls) | |||
681 | * Called when the iterate request is timedout | 683 | * Called when the iterate request is timedout |
682 | * | 684 | * |
683 | * @param cls a 'struct GNUNET_PEERSTORE_IterateContext *' | 685 | * @param cls a 'struct GNUNET_PEERSTORE_IterateContext *' |
686 | * @param tc Scheduler task context (unused) | ||
684 | */ | 687 | */ |
685 | static void | 688 | static void |
686 | iterate_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 689 | iterate_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -823,7 +826,7 @@ static void watch_request_sent (void *cls) | |||
823 | /** | 826 | /** |
824 | * Cancel a watch request | 827 | * Cancel a watch request |
825 | * | 828 | * |
826 | * @wc handle to the watch request | 829 | * @param wc handle to the watch request |
827 | */ | 830 | */ |
828 | void | 831 | void |
829 | GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc) | 832 | GNUNET_PEERSTORE_watch_cancel(struct GNUNET_PEERSTORE_WatchContext *wc) |
diff --git a/src/peerstore/peerstore_common.c b/src/peerstore/peerstore_common.c index 384a68f39..0cb801cc4 100644 --- a/src/peerstore/peerstore_common.c +++ b/src/peerstore/peerstore_common.c | |||
@@ -127,18 +127,19 @@ PEERSTORE_create_record_message(const char *sub_system, | |||
127 | * @param value record value BLOB (can be NULL) | 127 | * @param value record value BLOB (can be NULL) |
128 | * @param value_size record value size in bytes (set to 0 if value is NULL) | 128 | * @param value_size record value size in bytes (set to 0 if value is NULL) |
129 | * @param expiry time after which the record expires | 129 | * @param expiry time after which the record expires |
130 | * @param options options specific to the storage operation | ||
130 | * @param msg_type message type to be set in header | 131 | * @param msg_type message type to be set in header |
131 | * @return pointer to record message struct | 132 | * @return pointer to record message struct |
132 | */ | 133 | */ |
133 | struct GNUNET_MQ_Envelope * | 134 | struct GNUNET_MQ_Envelope * |
134 | PEERSTORE_create_record_mq_envelope(const char *sub_system, | 135 | PEERSTORE_create_record_mq_envelope(const char *sub_system, |
135 | const struct GNUNET_PeerIdentity *peer, | 136 | const struct GNUNET_PeerIdentity *peer, |
136 | const char *key, | 137 | const char *key, |
137 | const void *value, | 138 | const void *value, |
138 | size_t value_size, | 139 | size_t value_size, |
139 | struct GNUNET_TIME_Absolute *expiry, | 140 | struct GNUNET_TIME_Absolute *expiry, |
140 | enum GNUNET_PEERSTORE_StoreOption options, | 141 | enum GNUNET_PEERSTORE_StoreOption options, |
141 | uint16_t msg_type) | 142 | uint16_t msg_type) |
142 | { | 143 | { |
143 | struct StoreRecordMessage *srm; | 144 | struct StoreRecordMessage *srm; |
144 | struct GNUNET_MQ_Envelope *ev; | 145 | struct GNUNET_MQ_Envelope *ev; |
diff --git a/src/peerstore/peerstore_common.h b/src/peerstore/peerstore_common.h index 297eb9fc0..50ff4a2f9 100644 --- a/src/peerstore/peerstore_common.h +++ b/src/peerstore/peerstore_common.h | |||
@@ -66,18 +66,19 @@ PEERSTORE_create_record_message(const char *sub_system, | |||
66 | * @param value record value BLOB (can be NULL) | 66 | * @param value record value BLOB (can be NULL) |
67 | * @param value_size record value size in bytes (set to 0 if value is NULL) | 67 | * @param value_size record value size in bytes (set to 0 if value is NULL) |
68 | * @param expiry time after which the record expires | 68 | * @param expiry time after which the record expires |
69 | * @param options options specific to the storage operation | ||
69 | * @param msg_type message type to be set in header | 70 | * @param msg_type message type to be set in header |
70 | * @return pointer to record message struct | 71 | * @return pointer to record message struct |
71 | */ | 72 | */ |
72 | struct GNUNET_MQ_Envelope * | 73 | struct GNUNET_MQ_Envelope * |
73 | PEERSTORE_create_record_mq_envelope(const char *sub_system, | 74 | PEERSTORE_create_record_mq_envelope(const char *sub_system, |
74 | const struct GNUNET_PeerIdentity *peer, | 75 | const struct GNUNET_PeerIdentity *peer, |
75 | const char *key, | 76 | const char *key, |
76 | const void *value, | 77 | const void *value, |
77 | size_t value_size, | 78 | size_t value_size, |
78 | struct GNUNET_TIME_Absolute *expiry, | 79 | struct GNUNET_TIME_Absolute *expiry, |
79 | enum GNUNET_PEERSTORE_StoreOption options, | 80 | enum GNUNET_PEERSTORE_StoreOption options, |
80 | uint16_t msg_type); | 81 | uint16_t msg_type); |
81 | 82 | ||
82 | /** | 83 | /** |
83 | * Parses a message carrying a record | 84 | * Parses a message carrying a record |
diff --git a/src/peerstore/plugin_peerstore_sqlite.c b/src/peerstore/plugin_peerstore_sqlite.c index 0a0df4b0c..2726eef3d 100644 --- a/src/peerstore/plugin_peerstore_sqlite.c +++ b/src/peerstore/plugin_peerstore_sqlite.c | |||
@@ -284,21 +284,24 @@ peerstore_sqlite_iterate_records (void *cls, | |||
284 | * One key can store multiple values. | 284 | * One key can store multiple values. |
285 | * | 285 | * |
286 | * @param cls closure (internal context for the plugin) | 286 | * @param cls closure (internal context for the plugin) |
287 | * @param peer peer identity | ||
288 | * @param sub_system name of the GNUnet sub system responsible | 287 | * @param sub_system name of the GNUnet sub system responsible |
288 | * @param peer peer identity | ||
289 | * @param key record key string | ||
289 | * @param value value to be stored | 290 | * @param value value to be stored |
290 | * @param size size of value to be stored | 291 | * @param size size of value to be stored |
292 | * @param expiry absolute time after which the record is (possibly) deleted | ||
293 | * @param options options related to the store operation | ||
291 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 294 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
292 | */ | 295 | */ |
293 | static int | 296 | static int |
294 | peerstore_sqlite_store_record(void *cls, | 297 | peerstore_sqlite_store_record (void *cls, |
295 | const char *sub_system, | 298 | const char *sub_system, |
296 | const struct GNUNET_PeerIdentity *peer, | 299 | const struct GNUNET_PeerIdentity *peer, |
297 | const char *key, | 300 | const char *key, |
298 | const void *value, | 301 | const void *value, |
299 | size_t size, | 302 | size_t size, |
300 | struct GNUNET_TIME_Absolute expiry, | 303 | struct GNUNET_TIME_Absolute expiry, |
301 | enum GNUNET_PEERSTORE_StoreOption options) | 304 | enum GNUNET_PEERSTORE_StoreOption options) |
302 | { | 305 | { |
303 | struct Plugin *plugin = cls; | 306 | struct Plugin *plugin = cls; |
304 | sqlite3_stmt *stmt = plugin->insert_peerstoredata; | 307 | sqlite3_stmt *stmt = plugin->insert_peerstoredata; |