#include "gnunet_dht_service.h"
/* DEFINES */
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_EXTRA_LOGGING
#define MAX_GET_ATTEMPTS 10
}
if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
+ {
GNUNET_SCHEDULER_cancel (curr_get_ctx.retry_task);
+ curr_get_ctx.retry_task = GNUNET_SCHEDULER_NO_TASK;
+ }
}
{
const char *emsg = cls;
- fprintf (stderr,
- "Error: %s\n",
- emsg);
+ FPRINTF (stderr, "Error: %s\n", emsg);
if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
+ {
GNUNET_SCHEDULER_cancel (curr_get_ctx.retry_task);
-
+ curr_get_ctx.retry_task = GNUNET_SCHEDULER_NO_TASK;
+ }
if (curr_get_ctx.get_handle != NULL)
{
GNUNET_DHT_get_stop (curr_get_ctx.get_handle);
static void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- const struct GNUNET_PeerIdentity *const *get_path,
- const struct GNUNET_PeerIdentity *const *put_path,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ const struct GNUNET_PeerIdentity *get_path,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
struct PeerGetContext *get_context = cls;
if (0 !=
memcmp (&get_context->peer->hashPubKey, key, sizeof (GNUNET_HashCode)))
{
+ FPRINTF (stderr, "%s", "??\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Key returned is not the same key as was searched for!\n");
GNUNET_SCHEDULER_cancel (die_task);
"key mismatch in get response!\n");
return;
}
-
+ FPRINTF (stderr, "%s", "!\n");
if (get_context->retry_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (get_context->retry_task);
static void
stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
static void
get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
get_context->get_attempts);
else
{
+ FPRINTF (stderr, "%s", "?\n");
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Too many attempts failed, ending test!\n",
get_context->get_attempts);
"GET attempt failed, ending test!\n");
return;
}
+ FPRINTF (stderr, "%s", ".");
get_context->get_attempts++;
get_context->retry_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 10),
&stop_retry_get, get_context);
- fprintf (stderr,
- "Looking for key `%s'\n",
- GNUNET_h2s (&get_context->peer->hashPubKey));
- get_context->get_handle =
+ get_context->get_handle =
GNUNET_DHT_get_start (get_context->dht_handle,
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 5),
GNUNET_BLOCK_TYPE_DHT_HELLO,
- &get_context->peer->hashPubKey,
- DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL,
- 0, NULL, 0, &get_result_iterator, get_context);
+ &get_context->peer->hashPubKey, 1,
+ GNUNET_DHT_RO_NONE, NULL, 0, &get_result_iterator,
+ get_context);
}
+
static void
stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_SCHEDULER_add_now (&get_stop_finished, get_context);
}
+
static void
do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 10),
&stop_retry_get, get_context);
-
- fprintf (stderr,
- "Looking for key `%s'\n",
- GNUNET_h2s (&get_context->peer->hashPubKey));
- get_context->get_handle =
+ get_context->get_handle =
GNUNET_DHT_get_start (get_context->dht_handle,
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 5),
GNUNET_BLOCK_TYPE_DHT_HELLO,
- &get_context->peer->hashPubKey,
- DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL,
- 0, NULL, 0, &get_result_iterator, get_context);
+ &get_context->peer->hashPubKey, 1,
+ GNUNET_DHT_RO_FIND_PEER, NULL, 0,
+ &get_result_iterator, get_context);
}
#endif
GNUNET_SCHEDULER_cancel (die_task);
die_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &end_badly, "Timeout trying to GET");
+ GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
+ "Timeout trying to GET");
curr_get_ctx.dht_handle = peer1dht;
curr_get_ctx.peer = &peer2id;
{
if (emsg != NULL)
{
- fprintf (stderr,
- "Failed to start daemon: `%s'\n",
- emsg);
+ FPRINTF (stderr, "Failed to start daemon: `%s'\n", emsg);
return;
}
GNUNET_assert (id != NULL);