+/**
+ * Compute a random delay.
+ * A uniformly distributed value between mean + spread and mean - spread.
+ *
+ * For example for mean 4 min and spread 2 the minimum is (4 min - (1/2 * 4 min))
+ * It would return a random value between 2 and 6 min.
+ *
+ * @param mean the mean
+ * @param spread the inverse amount of deviation from the mean
+ */
+static struct GNUNET_TIME_Relative
+compute_rand_delay (struct GNUNET_TIME_Relative mean, unsigned int spread)
+{
+ struct GNUNET_TIME_Relative half_interval;
+ struct GNUNET_TIME_Relative ret;
+ unsigned int rand_delay;
+ unsigned int max_rand_delay;
+
+ if (0 == spread)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Not accepting spread of 0\n");
+ GNUNET_break (0);
+ }
+
+ /* Compute random time value between spread * mean and spread * mean */
+ half_interval = GNUNET_TIME_relative_divide (mean, spread);
+
+ max_rand_delay = GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us / mean.rel_value_us * (2/spread);
+ /**
+ * Compute random value between (0 and 1) * round_interval
+ * via multiplying round_interval with a 'fraction' (0 to value)/value
+ */
+ rand_delay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, max_rand_delay);
+ ret = GNUNET_TIME_relative_multiply (mean, rand_delay);
+ ret = GNUNET_TIME_relative_divide (ret, max_rand_delay);
+ ret = GNUNET_TIME_relative_add (ret, half_interval);
+
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == ret.rel_value_us)
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Returning FOREVER_REL\n");
+
+ return ret;
+}
+
+
+/**
+ * Send single pull request
+ *
+ * @param peer_id the peer to send the pull request to.
+ */
+static void
+send_pull_request (struct GNUNET_PeerIdentity *peer_id)
+{
+ struct GNUNET_MQ_Envelope *ev;
+ struct GNUNET_MQ_Handle *mq;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending PULL request to peer %s of gossiped list.\n",
+ GNUNET_i2s (peer_id));
+
+ GNUNET_array_append (pending_pull_reply_list, pending_pull_reply_list_size, *peer_id);
+
+ ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST);
+ mq = get_mq (peer_map, peer_id);
+ GNUNET_MQ_send (mq, ev);
+}
+
+
+/**
+ * Send single push
+ *
+ * @param peer_id the peer to send the push to.
+ */
+static void
+send_push (struct GNUNET_PeerIdentity *peer_id)
+{
+ struct GNUNET_MQ_Envelope *ev;
+ struct GNUNET_MQ_Handle *mq;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending PUSH to peer %s of gossiped list.\n",
+ GNUNET_i2s (peer_id));
+
+ ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH);
+ mq = get_mq (peer_map, peer_id);
+ GNUNET_MQ_send (mq, ev);
+}
+
+
+static void
+do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+static void
+do_mal_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+
+#ifdef ENABLE_MALICIOUS