[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27319 - gnunet/src/experimentation
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27319 - gnunet/src/experimentation |
Date: |
Tue, 28 May 2013 11:35:18 +0200 |
Author: wachs
Date: 2013-05-28 11:35:18 +0200 (Tue, 28 May 2013)
New Revision: 27319
Modified:
gnunet/src/experimentation/gnunet-daemon-experimentation_experiments.c
Log:
changes
Modified: gnunet/src/experimentation/gnunet-daemon-experimentation_experiments.c
===================================================================
--- gnunet/src/experimentation/gnunet-daemon-experimentation_experiments.c
2013-05-28 09:34:50 UTC (rev 27318)
+++ gnunet/src/experimentation/gnunet-daemon-experimentation_experiments.c
2013-05-28 09:35:18 UTC (rev 27319)
@@ -54,6 +54,11 @@
static struct GNUNET_CONTAINER_MultiHashMap *experiments;
+uint32_t GSE_my_issuer_count;
+
+struct Experimentation_Request_Issuer *GSE_my_issuer;
+
+
/**
* Verify experiment signature
*
@@ -102,7 +107,21 @@
return GNUNET_OK;
}
+int create_issuer (void *cls,
+ const struct
GNUNET_HashCode * key,
+ void *value)
+{
+ static int i = 0;
+ GNUNET_assert (i < GSE_my_issuer_count);
+ GSE_my_issuer[i].issuer_id.hashPubKey = *key;
+ i++;
+ return GNUNET_OK;
+
+}
+
+
+
/**
* Is peer a valid issuer
*
@@ -117,7 +136,52 @@
return GNUNET_NO;
}
+struct GetCtx
+{
+ struct Node *n;
+ GNUNET_EXPERIMENTATION_experiments_get_cb get_cb;
+};
+static int
+get_it (void *cls,
+ const struct GNUNET_HashCode * key,
+ void *value)
+{
+ struct GetCtx *get_ctx = cls;
+ struct Experiment *e = value;
+
+ /* Check compability */
+ if (get_ctx->n->version.abs_value != e->version.abs_value)
+ return GNUNET_OK;
+
+ get_ctx->get_cb (get_ctx->n, e);
+
+ return GNUNET_OK;
+}
+
+
+
+
+void
+GNUNET_EXPERIMENTATION_experiments_get (struct Node *n,
+
struct GNUNET_PeerIdentity *issuer,
+
GNUNET_EXPERIMENTATION_experiments_get_cb get_cb)
+{
+ struct GetCtx get_ctx;
+
+ GNUNET_assert (NULL != n);
+ GNUNET_assert (NULL != experiments);
+ GNUNET_assert (NULL != get_cb);
+
+ get_ctx.n = n;
+ get_ctx.get_cb = get_cb;
+
+ GNUNET_CONTAINER_multihashmap_get_multiple (experiments,
+ &issuer->hashPubKey, &get_it, &get_ctx);
+
+ get_cb (n, NULL);
+}
+
/**
* Add a new experiment
*/
@@ -146,8 +210,6 @@
e->duration = duration;
e->stop = stop;
-
-
/* verify experiment */
if (GNUNET_SYSERR == experiment_verify (i, e))
{
@@ -167,8 +229,6 @@
GNUNET_CONTAINER_multihashmap_put (experiments, &e->issuer.hashPubKey,
e, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GNUNET_STATISTICS_set (GSE_stats, "# experiments",
GNUNET_CONTAINER_multihashmap_size (experiments), GNUNET_NO);
- GNUNET_EXPERIMENTATION_scheduler_add (e);
-
return GNUNET_OK;
}
@@ -357,6 +417,11 @@
GNUNET_free (pubkey);
}
+ GSE_my_issuer_count = GNUNET_CONTAINER_multihashmap_size
(valid_issuers);
+ GSE_my_issuer = GNUNET_malloc (GSE_my_issuer_count * sizeof (struct
Experimentation_Request_Issuer));
+ GNUNET_CONTAINER_multihashmap_iterate (valid_issuers, &create_issuer,
GSE_my_issuer);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Daemon has %u issuers\n"),
GSE_my_issuer_count);
+
experiments = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
/* Load experiments from file */
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (GSE_cfg,
"EXPERIMENTATION", "EXPERIMENTS", &file))
@@ -380,6 +445,12 @@
void
GNUNET_EXPERIMENTATION_experiments_stop ()
{
+ if (NULL != GSE_my_issuer)
+ {
+ GNUNET_free (GSE_my_issuer);
+ GSE_my_issuer = NULL;
+ GSE_my_issuer_count = 0;
+ }
if (NULL != valid_issuers)
{
GNUNET_CONTAINER_multihashmap_iterate (valid_issuers,
&free_issuer, NULL);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27319 - gnunet/src/experimentation,
gnunet <=