summaryrefslogtreecommitdiff
path: root/src/rps/gnunet-rps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-rps.c')
-rw-r--r--src/rps/gnunet-rps.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c
index 03b2c8ab7..d2c497fd4 100644
--- a/src/rps/gnunet-rps.c
+++ b/src/rps/gnunet-rps.c
@@ -49,10 +49,20 @@ static struct GNUNET_PeerIdentity peer_id;
static int view_update;
/**
+ * @brief Do we want to receive updates of the view? (Option --view)
+ */
+static int stream_input;
+
+/**
* @brief Number of updates we want to receive
*/
static uint64_t num_view_updates;
+/**
+ * @brief Number of updates we want to receive
+ */
+static uint64_t num_stream_peers;
+
/**
* Task run when user presses CTRL-C to abort.
@@ -137,6 +147,22 @@ view_update_handle (void *cls,
/**
+ * Callback called on receipt of peer from biased stream
+ *
+ * @param n number of peers
+ * @param recv_peers the received peers
+ */
+static void
+stream_input_handle (void *cls,
+ const struct GNUNET_PeerIdentity *recv_peer)
+{
+ // TODO when source of peer is sent, also print source
+ FPRINTF (stdout, "%s\n",
+ GNUNET_i2s_full (recv_peer));
+}
+
+
+/**
* Main function that will be run by the scheduler.
*
* @param cls closure
@@ -163,7 +189,8 @@ run (void *cls,
}
if ((0 == memcmp (&zero_pid, &peer_id, sizeof (peer_id))) &&
- (!view_update))
+ (!view_update) &&
+ (!stream_input))
{ /* Request n PeerIDs */
/* If number was specified use it, else request single peer. */
if (NULL == args[0] ||
@@ -189,7 +216,23 @@ run (void *cls,
"Requesting %" PRIu64 " view updates\n", num_view_updates);
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting contiuous view updates\n");
+ "Requesting continuous view updates\n");
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
+ } else if (stream_input)
+ {
+ /* Get updates of view */
+ if (NULL == args[0] ||
+ 0 == sscanf (args[0], "%lu", &num_stream_peers))
+ {
+ num_stream_peers = 0;
+ }
+ GNUNET_RPS_stream_request (rps_handle, num_stream_peers, stream_input_handle, NULL);
+ if (0 != num_stream_peers)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Requesting %" PRIu64 " peers from biased stream\n", num_stream_peers);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Requesting continuous peers from biased stream\n");
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
}
else
@@ -223,6 +266,10 @@ main (int argc, char *const *argv)
"view",
gettext_noop ("Get updates of view (0 for infinite updates)"),
&view_update),
+ GNUNET_GETOPT_option_flag ('S',
+ "stream",
+ gettext_noop ("Get peers from biased stream"),
+ &stream_input),
GNUNET_GETOPT_OPTION_END
};
return (GNUNET_OK ==