2 This file is part of GNUnet.
3 (C) 2009 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 experimentation/gnunet-daemon-experimentation_experiments.c
23 * @brief experimentation daemon: experiment management
24 * @author Christian Grothoff
25 * @author Matthias Wachs
28 #include "gnunet_getopt_lib.h"
29 #include "gnunet_util_lib.h"
30 #include "gnunet_core_service.h"
31 #include "gnunet_statistics_service.h"
32 #include "gnunet-daemon-experimentation.h"
34 struct GNUNET_CONTAINER_MultiHashMap *issuer;
37 * Is peer a valid issuer
39 * @return GNUNET_YES or GNUNET_NO
42 GNUNET_EXPERIMENTATION_experiments_issuer_accepted (struct GNUNET_PeerIdentity *issuer_ID)
44 if (GNUNET_CONTAINER_multihashmap_contains (issuer, &issuer_ID->hashPubKey))
52 * Start experiments management
55 GNUNET_EXPERIMENTATION_experiments_start ()
59 struct GNUNET_PeerIdentity issuer_ID;
61 /* Load valid issuer */
62 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (GSE_cfg, "EXPERIMENTATION", "ISSUERS", &issuers))
64 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n"));
68 issuer = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
70 for (pos = strtok (issuers, " "); pos != NULL; pos = strtok (NULL, " "))
73 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (pos, &issuer_ID.hashPubKey))
75 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid value `%s'\n"), pos);
79 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "`%s' is a valid issuer \n", GNUNET_i2s (&issuer_ID));
80 GNUNET_CONTAINER_multihashmap_put (issuer, &issuer_ID.hashPubKey,
81 NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
84 GNUNET_free (issuers);
86 if (0 == GNUNET_CONTAINER_multihashmap_size (issuer))
88 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No valid experiment issuers configured! Set value to peer id of issuer! Exit...\n"));
89 GNUNET_EXPERIMENTATION_experiments_stop ();
93 GNUNET_STATISTICS_set (GSE_stats, "# issuer", GNUNET_CONTAINER_multihashmap_size (issuer), GNUNET_NO);
98 * Stop experiments management
101 GNUNET_EXPERIMENTATION_experiments_stop ()
104 GNUNET_CONTAINER_multihashmap_destroy (issuer);
108 /* end of gnunet-daemon-experimentation_experiments.c */