2 * This file is part of GNUnet
3 * Copyright (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., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 * @file psycstore/gnunet-service-psycstore.c
23 * @brief PSYCstore service
24 * @author Gabor X Toth
25 * @author Christian Grothoff
31 #include "gnunet_util_lib.h"
32 #include "gnunet_constants.h"
33 #include "gnunet_protocols.h"
34 #include "gnunet_statistics_service.h"
35 #include "gnunet_psycstore_service.h"
36 #include "gnunet_psycstore_plugin.h"
37 #include "psycstore.h"
41 * Handle to our current configuration.
43 static const struct GNUNET_CONFIGURATION_Handle *cfg;
46 * Handle to the statistics service.
48 static struct GNUNET_STATISTICS_Handle *stats;
51 * Notification context, simplifies client broadcasts.
53 static struct GNUNET_SERVER_NotificationContext *nc;
58 static struct GNUNET_PSYCSTORE_PluginFunctions *db;
61 * Name of the database plugin
63 static char *db_lib_name;
67 * Task run during shutdown.
73 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
77 GNUNET_SERVER_notification_context_destroy (nc);
82 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
85 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db));
86 GNUNET_free (db_lib_name);
92 * Send a result code back to the client.
95 * Client that should receive the result code.
99 * Operation ID in network byte order.
101 * Error message to include (or NULL for none).
104 send_result_code (struct GNUNET_SERVER_Client *client, uint64_t op_id,
105 int64_t result_code, const char *err_msg)
107 struct OperationResult *res;
111 err_size = strnlen (err_msg,
112 GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (*res) - 1) + 1;
113 res = GNUNET_malloc (sizeof (struct OperationResult) + err_size);
114 res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE);
115 res->header.size = htons (sizeof (struct OperationResult) + err_size);
116 res->result_code = GNUNET_htonll (result_code - INT64_MIN);
120 memcpy (&res[1], err_msg, err_size);
121 ((char *) &res[1])[err_size - 1] = '\0';
123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
124 "Sending result to client: %" PRId64 " (%s)\n",
125 result_code, err_msg);
126 GNUNET_SERVER_notification_context_add (nc, client);
127 GNUNET_SERVER_notification_context_unicast (nc, client, &res->header,
135 MEMBERSHIP_TEST_NOT_NEEDED = 0,
136 MEMBERSHIP_TEST_NEEDED = 1,
137 MEMBERSHIP_TEST_DONE = 2,
138 } MessageMembershipTest;
143 struct GNUNET_SERVER_Client *client;
146 * Channel's public key.
148 struct GNUNET_CRYPTO_EddsaPublicKey channel_key;
151 * Slave's public key.
153 struct GNUNET_CRYPTO_EcdsaPublicKey slave_key;
161 * Membership test result.
163 int membership_test_result;
166 * Do membership test with @a slave_key before returning fragment?
167 * @see enum MessageMembershipTest
169 uint8_t membership_test;
174 send_fragment (void *cls, struct GNUNET_MULTICAST_MessageHeader *msg,
175 enum GNUNET_PSYCSTORE_MessageFlags flags)
177 struct SendClosure *sc = cls;
178 struct FragmentResult *res;
180 if (MEMBERSHIP_TEST_NEEDED == sc->membership_test)
182 sc->membership_test = MEMBERSHIP_TEST_DONE;
183 sc->membership_test_result
184 = db->membership_test (db->cls, &sc->channel_key, &sc->slave_key,
185 GNUNET_ntohll (msg->message_id));
186 switch (sc->membership_test_result)
197 size_t msg_size = ntohs (msg->header.size);
199 res = GNUNET_malloc (sizeof (struct FragmentResult) + msg_size);
200 res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_FRAGMENT);
201 res->header.size = htons (sizeof (struct FragmentResult) + msg_size);
202 res->op_id = sc->op_id;
203 res->psycstore_flags = htonl (flags);
204 memcpy (&res[1], msg, msg_size);
205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
206 "Sending fragment %ld to client\n",
207 GNUNET_ntohll (msg->fragment_id));
209 GNUNET_SERVER_notification_context_add (nc, sc->client);
210 GNUNET_SERVER_notification_context_unicast (nc, sc->client, &res->header,
218 send_state_var (void *cls, const char *name,
219 const void *value, size_t value_size)
221 struct SendClosure *sc = cls;
222 struct StateResult *res;
223 size_t name_size = strlen (name) + 1;
225 /** @todo FIXME: split up value into 64k chunks */
227 res = GNUNET_malloc (sizeof (struct StateResult) + name_size + value_size);
228 res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_STATE);
229 res->header.size = htons (sizeof (struct StateResult) + name_size + value_size);
230 res->op_id = sc->op_id;
231 res->name_size = htons (name_size);
232 memcpy (&res[1], name, name_size);
233 memcpy ((char *) &res[1] + name_size, value, value_size);
234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
235 "Sending state variable %s to client\n", name);
236 GNUNET_SERVER_notification_context_add (nc, sc->client);
237 GNUNET_SERVER_notification_context_unicast (nc, sc->client, &res->header,
245 handle_membership_store (void *cls,
246 struct GNUNET_SERVER_Client *client,
247 const struct GNUNET_MessageHeader *msg)
249 const struct MembershipStoreRequest *req =
250 (const struct MembershipStoreRequest *) msg;
252 int ret = db->membership_store (db->cls, &req->channel_key, &req->slave_key,
254 GNUNET_ntohll (req->announced_at),
255 GNUNET_ntohll (req->effective_since),
256 GNUNET_ntohll (req->group_generation));
258 if (ret != GNUNET_OK)
259 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
260 _("Failed to store membership information!\n"));
262 send_result_code (client, req->op_id, ret, NULL);
263 GNUNET_SERVER_receive_done (client, GNUNET_OK);
268 handle_membership_test (void *cls,
269 struct GNUNET_SERVER_Client *client,
270 const struct GNUNET_MessageHeader *msg)
272 const struct MembershipTestRequest *req =
273 (const struct MembershipTestRequest *) msg;
275 int ret = db->membership_test (db->cls, &req->channel_key, &req->slave_key,
276 GNUNET_ntohll (req->message_id));
283 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
284 _("Failed to test membership!\n"));
287 send_result_code (client, req->op_id, ret, NULL);
288 GNUNET_SERVER_receive_done (client, GNUNET_OK);
293 handle_fragment_store (void *cls,
294 struct GNUNET_SERVER_Client *client,
295 const struct GNUNET_MessageHeader *msg)
297 const struct FragmentStoreRequest *req =
298 (const struct FragmentStoreRequest *) msg;
300 int ret = db->fragment_store (db->cls, &req->channel_key,
301 (const struct GNUNET_MULTICAST_MessageHeader *)
302 &req[1], ntohl (req->psycstore_flags));
304 if (ret != GNUNET_OK)
305 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
306 _("Failed to store fragment!\n"));
308 send_result_code (client, req->op_id, ret, NULL);
309 GNUNET_SERVER_receive_done (client, GNUNET_OK);
314 handle_fragment_get (void *cls,
315 struct GNUNET_SERVER_Client *client,
316 const struct GNUNET_MessageHeader *msg)
318 const struct FragmentGetRequest *
319 req = (const struct FragmentGetRequest *) msg;
321 sc = { .op_id = req->op_id, .client = client,
322 .channel_key = req->channel_key, .slave_key = req->slave_key,
323 .membership_test = req->do_membership_test };
326 uint64_t ret_frags = 0;
327 uint64_t first_fragment_id = GNUNET_ntohll (req->first_fragment_id);
328 uint64_t last_fragment_id = GNUNET_ntohll (req->last_fragment_id);
329 uint64_t limit = GNUNET_ntohll (req->fragment_limit);
332 ret = db->fragment_get (db->cls, &req->channel_key,
333 first_fragment_id, last_fragment_id,
334 &ret_frags, &send_fragment, &sc);
336 ret = db->fragment_get_latest (db->cls, &req->channel_key, limit,
337 &ret_frags, &send_fragment, &sc);
343 if (MEMBERSHIP_TEST_DONE == sc.membership_test)
345 switch (sc.membership_test_result)
351 ret = GNUNET_PSYCSTORE_MEMBERSHIP_TEST_FAILED;
361 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
362 _("Failed to get fragment!\n"));
364 send_result_code (client, req->op_id, (ret < 0) ? ret : ret_frags, NULL);
365 GNUNET_SERVER_receive_done (client, GNUNET_OK);
370 handle_message_get (void *cls,
371 struct GNUNET_SERVER_Client *client,
372 const struct GNUNET_MessageHeader *msg)
374 const struct MessageGetRequest *
375 req = (const struct MessageGetRequest *) msg;
376 uint16_t size = ntohs (msg->size);
377 const char *method_prefix = (const char *) &req[1];
379 if (size < sizeof (*req) + 1
380 || '\0' != method_prefix[size - sizeof (*req) - 1])
382 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
383 "Message get: invalid method prefix. size: %u < %u?\n",
384 size, sizeof (*req) + 1);
386 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
391 sc = { .op_id = req->op_id, .client = client,
392 .channel_key = req->channel_key, .slave_key = req->slave_key,
393 .membership_test = req->do_membership_test };
396 uint64_t ret_frags = 0;
397 uint64_t first_message_id = GNUNET_ntohll (req->first_message_id);
398 uint64_t last_message_id = GNUNET_ntohll (req->last_message_id);
399 uint64_t limit = GNUNET_ntohll (req->message_limit);
401 /** @todo method_prefix */
403 ret = db->message_get (db->cls, &req->channel_key,
404 first_message_id, last_message_id,
405 &ret_frags, &send_fragment, &sc);
407 ret = db->message_get_latest (db->cls, &req->channel_key, limit,
408 &ret_frags, &send_fragment, &sc);
416 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
417 _("Failed to get message!\n"));
420 send_result_code (client, req->op_id, (ret < 0) ? ret : ret_frags, NULL);
421 GNUNET_SERVER_receive_done (client, GNUNET_OK);
426 handle_message_get_fragment (void *cls,
427 struct GNUNET_SERVER_Client *client,
428 const struct GNUNET_MessageHeader *msg)
430 const struct MessageGetFragmentRequest *
431 req = (const struct MessageGetFragmentRequest *) msg;
433 sc = { .op_id = req->op_id, .client = client,
434 .channel_key = req->channel_key, .slave_key = req->slave_key,
435 .membership_test = req->do_membership_test };
437 int ret = db->message_get_fragment (db->cls, &req->channel_key,
438 GNUNET_ntohll (req->message_id),
439 GNUNET_ntohll (req->fragment_offset),
440 &send_fragment, &sc);
447 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
448 _("Failed to get message fragment!\n"));
451 send_result_code (client, req->op_id, ret, NULL);
452 GNUNET_SERVER_receive_done (client, GNUNET_OK);
457 handle_counters_get (void *cls,
458 struct GNUNET_SERVER_Client *client,
459 const struct GNUNET_MessageHeader *msg)
461 const struct OperationRequest *req = (const struct OperationRequest *) msg;
462 struct CountersResult res = { {0} };
464 int ret = db->counters_message_get (db->cls, &req->channel_key,
465 &res.max_fragment_id, &res.max_message_id,
466 &res.max_group_generation);
470 ret = db->counters_state_get (db->cls, &req->channel_key,
471 &res.max_state_message_id);
475 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
476 _("Failed to get master counters!\n"));
479 res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS);
480 res.header.size = htons (sizeof (res));
481 res.result_code = htonl (ret - INT32_MIN);
482 res.op_id = req->op_id;
483 res.max_fragment_id = GNUNET_htonll (res.max_fragment_id);
484 res.max_message_id = GNUNET_htonll (res.max_message_id);
485 res.max_group_generation = GNUNET_htonll (res.max_group_generation);
486 res.max_state_message_id = GNUNET_htonll (res.max_state_message_id);
488 GNUNET_SERVER_notification_context_add (nc, client);
489 GNUNET_SERVER_notification_context_unicast (nc, client, &res.header,
492 GNUNET_SERVER_receive_done (client, GNUNET_OK);
496 /** @todo FIXME: stop processing further state modify messages after an error */
498 handle_state_modify (void *cls,
499 struct GNUNET_SERVER_Client *client,
500 const struct GNUNET_MessageHeader *msg)
502 const struct StateModifyRequest *req
503 = (const struct StateModifyRequest *) msg;
505 int ret = GNUNET_SYSERR;
506 const char *name = (const char *) &req[1];
507 uint16_t name_size = ntohs (req->name_size);
509 if (name_size <= 2 || '\0' != name[name_size - 1])
511 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
512 _("Tried to set invalid state variable name!\n"));
519 if (req->flags & STATE_OP_FIRST)
521 ret = db->state_modify_begin (db->cls, &req->channel_key,
522 GNUNET_ntohll (req->message_id),
523 GNUNET_ntohll (req->state_delta));
525 if (ret != GNUNET_OK)
527 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
528 _("Failed to begin modifying state!\n"));
534 case GNUNET_ENV_OP_ASSIGN:
535 ret = db->state_modify_set (db->cls, &req->channel_key,
536 (const char *) &req[1],
537 name + ntohs (req->name_size),
538 ntohs (req->header.size) - sizeof (*req)
539 - ntohs (req->name_size));
543 ret = GNUNET_ENV_operation ((const char *) &req[1],
544 current_value, current_value_size,
545 req->oper, name + ntohs (req->name_size),
546 ntohs (req->header.size) - sizeof (*req)
547 - ntohs (req->name_size), &value, &value_size);
550 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
551 _("Unknown operator: %c\n"), req->oper);
555 if (GNUNET_OK == ret && req->flags & STATE_OP_LAST)
557 ret = db->state_modify_end (db->cls, &req->channel_key,
558 GNUNET_ntohll (req->message_id));
559 if (ret != GNUNET_OK)
560 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
561 _("Failed to end modifying state!\n"));
564 send_result_code (client, req->op_id, ret, NULL);
565 GNUNET_SERVER_receive_done (client, GNUNET_OK);
569 /** @todo FIXME: stop processing further state sync messages after an error */
571 handle_state_sync (void *cls,
572 struct GNUNET_SERVER_Client *client,
573 const struct GNUNET_MessageHeader *msg)
575 const struct StateSyncRequest *req
576 = (const struct StateSyncRequest *) msg;
578 int ret = GNUNET_SYSERR;
579 const char *name = (const char *) &req[1];
580 uint16_t name_size = ntohs (req->name_size);
582 if (name_size <= 2 || '\0' != name[name_size - 1])
584 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
585 _("Tried to set invalid state variable name!\n"));
592 if (req->flags & STATE_OP_FIRST)
594 ret = db->state_sync_begin (db->cls, &req->channel_key);
596 if (ret != GNUNET_OK)
598 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
599 _("Failed to begin synchronizing state!\n"));
603 ret = db->state_sync_set (db->cls, &req->channel_key, name,
604 name + ntohs (req->name_size),
605 ntohs (req->header.size) - sizeof (*req)
606 - ntohs (req->name_size));
609 if (GNUNET_OK == ret && req->flags & STATE_OP_LAST)
611 ret = db->state_sync_end (db->cls, &req->channel_key,
612 GNUNET_ntohll (req->message_id));
613 if (ret != GNUNET_OK)
614 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
615 _("Failed to end synchronizing state!\n"));
618 send_result_code (client, req->op_id, ret, NULL);
619 GNUNET_SERVER_receive_done (client, GNUNET_OK);
624 handle_state_reset (void *cls,
625 struct GNUNET_SERVER_Client *client,
626 const struct GNUNET_MessageHeader *msg)
628 const struct OperationRequest *req =
629 (const struct OperationRequest *) msg;
631 int ret = db->state_reset (db->cls, &req->channel_key);
633 if (ret != GNUNET_OK)
634 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
635 _("Failed to reset state!\n"));
637 send_result_code (client, req->op_id, ret, NULL);
638 GNUNET_SERVER_receive_done (client, GNUNET_OK);
643 handle_state_hash_update (void *cls,
644 struct GNUNET_SERVER_Client *client,
645 const struct GNUNET_MessageHeader *msg)
647 const struct OperationRequest *req =
648 (const struct OperationRequest *) msg;
650 int ret = db->state_reset (db->cls, &req->channel_key);
652 if (ret != GNUNET_OK)
653 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
654 _("Failed to reset state!\n"));
656 send_result_code (client, req->op_id, ret, NULL);
657 GNUNET_SERVER_receive_done (client, GNUNET_OK);
662 handle_state_get (void *cls,
663 struct GNUNET_SERVER_Client *client,
664 const struct GNUNET_MessageHeader *msg)
666 const struct OperationRequest *req =
667 (const struct OperationRequest *) msg;
669 struct SendClosure sc = { .op_id = req->op_id, .client = client };
670 int64_t ret = GNUNET_SYSERR;
671 const char *name = (const char *) &req[1];
672 uint16_t name_size = ntohs (req->header.size) - sizeof (*req);
674 if (name_size <= 2 || '\0' != name[name_size - 1])
676 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
677 _("Tried to get invalid state variable name!\n"));
682 ret = db->state_get (db->cls, &req->channel_key, name,
683 &send_state_var, &sc);
684 if (GNUNET_NO == ret && name_size >= 5) /* min: _a_b\0 */
686 char *p, *n = GNUNET_malloc (name_size);
687 memcpy (n, name, name_size);
688 while (&n[1] < (p = strrchr (n, '_')) && GNUNET_NO == ret)
691 ret = db->state_get (db->cls, &req->channel_key, n,
692 &send_state_var, &sc);
703 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
704 _("Failed to get state variable!\n"));
707 send_result_code (client, req->op_id, ret, NULL);
708 GNUNET_SERVER_receive_done (client, GNUNET_OK);
713 handle_state_get_prefix (void *cls,
714 struct GNUNET_SERVER_Client *client,
715 const struct GNUNET_MessageHeader *msg)
717 const struct OperationRequest *req =
718 (const struct OperationRequest *) msg;
720 struct SendClosure sc = { .op_id = req->op_id, .client = client };
721 int64_t ret = GNUNET_SYSERR;
722 const char *name = (const char *) &req[1];
723 uint16_t name_size = ntohs (req->header.size) - sizeof (*req);
725 if (name_size <= 1 || '\0' != name[name_size - 1])
727 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
728 _("Tried to get invalid state variable name!\n"));
733 ret = db->state_get_prefix (db->cls, &req->channel_key, name,
734 &send_state_var, &sc);
742 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
743 _("Failed to get state variable!\n"));
746 send_result_code (client, req->op_id, ret, NULL);
747 GNUNET_SERVER_receive_done (client, GNUNET_OK);
752 * Initialize the PSYCstore service.
754 * @param cls Closure.
755 * @param server The initialized server.
756 * @param c Configuration to use.
759 run (void *cls, struct GNUNET_SERVER_Handle *server,
760 const struct GNUNET_CONFIGURATION_Handle *c)
762 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
763 { &handle_membership_store, NULL,
764 GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_STORE,
765 sizeof (struct MembershipStoreRequest) },
767 { &handle_membership_test, NULL,
768 GNUNET_MESSAGE_TYPE_PSYCSTORE_MEMBERSHIP_TEST,
769 sizeof (struct MembershipTestRequest) },
771 { &handle_fragment_store, NULL,
772 GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_STORE, 0, },
774 { &handle_fragment_get, NULL,
775 GNUNET_MESSAGE_TYPE_PSYCSTORE_FRAGMENT_GET,
776 sizeof (struct FragmentGetRequest) },
778 { &handle_message_get, NULL,
779 GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET, 0 },
781 { &handle_message_get_fragment, NULL,
782 GNUNET_MESSAGE_TYPE_PSYCSTORE_MESSAGE_GET_FRAGMENT,
783 sizeof (struct MessageGetFragmentRequest) },
785 { &handle_counters_get, NULL,
786 GNUNET_MESSAGE_TYPE_PSYCSTORE_COUNTERS_GET,
787 sizeof (struct OperationRequest) },
789 { &handle_state_modify, NULL,
790 GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_MODIFY, 0 },
792 { &handle_state_sync, NULL,
793 GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_SYNC, 0 },
795 { &handle_state_reset, NULL,
796 GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_RESET,
797 sizeof (struct OperationRequest) },
799 { &handle_state_hash_update, NULL,
800 GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_HASH_UPDATE,
801 sizeof (struct StateHashUpdateRequest) },
803 { &handle_state_get, NULL,
804 GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_GET, 0 },
806 { &handle_state_get_prefix, NULL,
807 GNUNET_MESSAGE_TYPE_PSYCSTORE_STATE_GET_PREFIX, 0 },
814 /* Loading database plugin */
817 GNUNET_CONFIGURATION_get_value_string (cfg, "psycstore", "database",
820 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
824 GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_psycstore_%s", database);
825 db = GNUNET_PLUGIN_load (db_lib_name, (void *) cfg);
826 GNUNET_free (database);
830 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
831 "Could not load database backend `%s'\n",
833 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
837 stats = GNUNET_STATISTICS_create ("psycstore", cfg);
838 GNUNET_SERVER_add_handlers (server, handlers);
839 nc = GNUNET_SERVER_notification_context_create (server, 1);
840 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
846 * The main function for the service.
848 * @param argc number of arguments from the command line
849 * @param argv command line arguments
850 * @return 0 ok, 1 on error
853 main (int argc, char *const *argv)
856 GNUNET_SERVICE_run (argc, argv, "psycstore",
857 GNUNET_SERVICE_OPTION_NONE,
858 &run, NULL)) ? 0 : 1;
862 /* end of gnunet-service-psycstore.c */