Adding a function pick_random_friend ()
[oweals/gnunet.git] / src / dht / gnunet-dht-get.c
index 2dff4767f2c8567c7032aa1af15ab05994a8023e..db4d43fe79d777d58504e8ca8263bd3c5cbaddb4 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -26,6 +26,7 @@
 #include "platform.h"
 #include "gnunet_dht_service.h"
 
+#define LOG(kind,...) GNUNET_log_from (kind, "dht-clients",__VA_ARGS__)
 /**
  * The type of the query
  */
@@ -51,6 +52,11 @@ static struct GNUNET_TIME_Relative timeout_request = { 60000 };
  */
 static int verbose;
 
+/**
+ * Use DHT demultixplex_everywhere
+ */
+static int demultixplex_everywhere;
+
 /**
  * Handle to the DHT
  */
@@ -123,8 +129,8 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
                      unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
                      size_t size, const void *data)
 {
-  FPRINTF (stdout, 
-          _("Result %d, type %d:\n%.*s\n"), 
+  FPRINTF (stdout,
+          _("Result %d, type %d:\n%.*s\n"),
           result_count, type,
            (unsigned int) size, (char *) data);
   result_count++;
@@ -145,6 +151,8 @@ run (void *cls, char *const *args, const char *cfgfile,
 {
   struct GNUNET_HashCode key;
 
+
+
   cfg = c;
   if (NULL == query_key)
   {
@@ -161,12 +169,14 @@ run (void *cls, char *const *args, const char *cfgfile,
   if (query_type == GNUNET_BLOCK_TYPE_ANY)      /* Type of data not set */
     query_type = GNUNET_BLOCK_TYPE_TEST;
   GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key);
+  if (verbose)
+    FPRINTF (stderr, "%s `%s' \n",  _("Issueing DHT GET with key"), GNUNET_h2s_full (&key));
   GNUNET_SCHEDULER_add_delayed (timeout_request,
                                &cleanup_task, NULL);
   get_handle =
       GNUNET_DHT_get_start (dht_handle, query_type, &key, replication,
-                            GNUNET_DHT_RO_NONE, NULL, 0, &get_result_iterator,
-                            NULL);
+                            (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE,
+                            NULL, 0, &get_result_iterator, NULL);
 
 }
 
@@ -187,6 +197,9 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
   {'T', "timeout", "TIMEOUT",
    gettext_noop ("how long to execute this query before giving up?"),
    1, &GNUNET_GETOPT_set_relative_time, &timeout_request},
+  {'x', "demultiplex", NULL,
+    gettext_noop ("use DHT's demultiplex everywhere option"),
+    0, &GNUNET_GETOPT_set_one, &demultixplex_everywhere},
   {'V', "verbose", NULL,
    gettext_noop ("be verbose (print progress information)"),
    0, &GNUNET_GETOPT_set_one, &verbose},